Rezultati

Up. imeNalogaJezikRezultatČas oddaje
snajper Podnapisi Java 100/100OK 10. maj '18 @ 18:08

Test Točke Porabljen spomin Porabljen čas Status
#1 7/7 52,680 MiB 0,141 s OK
#2 7/7 59,555 MiB 0,425 s OK
#3 7/7 39,910 MiB 0,000 s OK
#4 7/7 83,164 MiB 0,776 s OK
#5 7/7 37,371 MiB 0,000 s OK
#6 7/7 39,410 MiB 0,000 s OK
#7 7/7 39,566 MiB 0,000 s OK
#8 7/7 38,781 MiB 0,000 s OK
#9 7/7 35,156 MiB 0,000 s OK
#10 7/7 80,055 MiB 0,649 s OK
#11 7/7 38,711 MiB 0,000 s OK
#12 7/7 58,777 MiB 0,112 s OK
#13 8/8 60,578 MiB 0,173 s OK
#14 8/8 38,117 MiB 0,000 s OK

Ocenjevani program (Podnapisi.java):
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created by snajper on 5/10/18.
 */
public class Podnapisi {

    static class Cas {
        int h, m, s, ms;

        public void set(String str) {
            h = Integer.parseInt(str.substring(0, 2));
            m = Integer.parseInt(str.substring(3, 5));
            s = Integer.parseInt(str.substring(6, 8));
            ms= Integer.parseInt(str.substring(9, 12));
        }

        @Override
        public String toString() {
            //return String.format("%02d:%02d:%02d,%03d", h, m, s, ms);
            return (h >= 10 ? ("" + h) : (h == 0 ? ("00") : ("0" + h))) + ":" +
                    (m >= 10 ? ("" + m) : (m == 0 ? ("00") : ("0" + m))) + ":" +
                    (s >= 10 ? ("" + s) : (s == 0 ? ("00") : ("0" + s))) + "," +
                    (ms >= 100 ? ("" + ms) : (ms >= 10 ? ("0" + ms) : (ms > 0 ? ("00" + ms) : "000")));
        }

        public void add(Cas shift) {
            h += shift.h;
            m += shift.m;
            s += shift.s;
            ms += shift.ms;

            if (ms >= 1000) {
                ms -= 1000;
                s++;
            }
            if (s >= 60) {
                s -= 60;
                m++;
            }
            if (m >= 60) {
                m -= 60;
                h++;
            }
        }
    }

    public static void main(String[] args) {
        Scanner in;

        if (args.length == 0) {
            in = new Scanner(System.in);
        } else {
            try {
                in = new Scanner(new File(args[0]));
            } catch (FileNotFoundException e) {
                throw new Error();
            }
        }

        in.next();
        Cas shift = new Cas();
        shift.set(in.next());
        in.nextLine();

        Cas startTime = new Cas();
        Cas endTime = new Cas();

        while (in.hasNext()) {
            String header = in.nextLine();
            startTime.set(in.next());
            startTime.add(shift);
            in.next();
            endTime.set(in.next());
            endTime.add(shift);
            in.nextLine();

            System.out.println(header);
            System.out.println(startTime + " --> " + endTime);

            String vrstica;
            do {
                if (!in.hasNext()) {
                    return;
                }
                vrstica = in.nextLine();
                System.out.println(vrstica);
            } while (!vrstica.isEmpty());
        }
    }
}