Submission #170102

# Submission time Handle Problem Language Result Execution time Memory
170102 2019-12-24T02:45:02 Z ijxjdjd Remittance (JOI19_remittance) Java 11
55 / 100
1000 ms 118380 KB
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ijxjdjd
 */
public class remittance {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        remittanc solver = new remittanc();
        solver.solve(1, in, out);
        out.close();
    }

    static class remittanc {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long last = 0;
            long max = 0;
            long[] A = new long[N];
            long[] B = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
                B[i] = in.nextInt();
            }
            boolean first = true;
//        while (last > 0 || first) {
            for (int j = 0; j < 1000; j++) {
                for (int i = 0; i < N; i++) {
                    if (A[i] > B[i]) {
                        if (A[i] - 2 * ((A[i] - B[i] + 1) / 2) < 0) {
                            continue;
                        }
                        last = ((A[i] - B[i]) + 1) / 2;
                        A[i] -= last * 2;
                    } else {
                        last = 0;
                    }
                    A[(i + 1) % N] += last;
                }
//            }
            }
            for (int i = 0; i < N; i++) {
                if (A[i] != B[i]) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

# Verdict Execution time Memory Grader output
1 Correct 85 ms 9612 KB Output is correct
2 Correct 90 ms 9720 KB Output is correct
3 Correct 84 ms 9456 KB Output is correct
4 Correct 85 ms 9756 KB Output is correct
5 Correct 88 ms 9788 KB Output is correct
6 Correct 88 ms 9728 KB Output is correct
7 Correct 87 ms 9700 KB Output is correct
8 Correct 87 ms 9732 KB Output is correct
9 Correct 91 ms 9724 KB Output is correct
10 Correct 88 ms 9820 KB Output is correct
11 Correct 84 ms 9624 KB Output is correct
12 Correct 90 ms 9800 KB Output is correct
13 Correct 85 ms 9596 KB Output is correct
14 Correct 86 ms 9716 KB Output is correct
15 Correct 85 ms 9576 KB Output is correct
16 Correct 84 ms 9704 KB Output is correct
17 Correct 85 ms 9612 KB Output is correct
18 Correct 90 ms 9712 KB Output is correct
19 Correct 86 ms 9724 KB Output is correct
20 Correct 87 ms 9584 KB Output is correct
21 Correct 84 ms 9620 KB Output is correct
22 Correct 91 ms 9716 KB Output is correct
23 Correct 86 ms 9696 KB Output is correct
24 Correct 84 ms 9688 KB Output is correct
25 Correct 87 ms 9836 KB Output is correct
26 Correct 92 ms 9852 KB Output is correct
27 Correct 87 ms 9924 KB Output is correct
28 Correct 88 ms 9612 KB Output is correct
29 Correct 87 ms 9704 KB Output is correct
30 Correct 87 ms 9652 KB Output is correct
31 Correct 86 ms 9840 KB Output is correct
32 Correct 87 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 9612 KB Output is correct
2 Correct 90 ms 9720 KB Output is correct
3 Correct 84 ms 9456 KB Output is correct
4 Correct 85 ms 9756 KB Output is correct
5 Correct 88 ms 9788 KB Output is correct
6 Correct 88 ms 9728 KB Output is correct
7 Correct 87 ms 9700 KB Output is correct
8 Correct 87 ms 9732 KB Output is correct
9 Correct 91 ms 9724 KB Output is correct
10 Correct 88 ms 9820 KB Output is correct
11 Correct 84 ms 9624 KB Output is correct
12 Correct 90 ms 9800 KB Output is correct
13 Correct 85 ms 9596 KB Output is correct
14 Correct 86 ms 9716 KB Output is correct
15 Correct 85 ms 9576 KB Output is correct
16 Correct 84 ms 9704 KB Output is correct
17 Correct 85 ms 9612 KB Output is correct
18 Correct 90 ms 9712 KB Output is correct
19 Correct 86 ms 9724 KB Output is correct
20 Correct 87 ms 9584 KB Output is correct
21 Correct 84 ms 9620 KB Output is correct
22 Correct 91 ms 9716 KB Output is correct
23 Correct 86 ms 9696 KB Output is correct
24 Correct 84 ms 9688 KB Output is correct
25 Correct 87 ms 9836 KB Output is correct
26 Correct 92 ms 9852 KB Output is correct
27 Correct 87 ms 9924 KB Output is correct
28 Correct 88 ms 9612 KB Output is correct
29 Correct 87 ms 9704 KB Output is correct
30 Correct 87 ms 9652 KB Output is correct
31 Correct 86 ms 9840 KB Output is correct
32 Correct 87 ms 9676 KB Output is correct
33 Correct 90 ms 9756 KB Output is correct
34 Correct 87 ms 9776 KB Output is correct
35 Correct 88 ms 9984 KB Output is correct
36 Correct 87 ms 9772 KB Output is correct
37 Correct 86 ms 9676 KB Output is correct
38 Correct 84 ms 9564 KB Output is correct
39 Correct 85 ms 9732 KB Output is correct
40 Correct 92 ms 9900 KB Output is correct
41 Correct 91 ms 9580 KB Output is correct
42 Correct 86 ms 9640 KB Output is correct
43 Correct 86 ms 9596 KB Output is correct
44 Correct 87 ms 9592 KB Output is correct
45 Correct 87 ms 9656 KB Output is correct
46 Correct 88 ms 9608 KB Output is correct
47 Correct 89 ms 9700 KB Output is correct
48 Correct 89 ms 9556 KB Output is correct
49 Correct 102 ms 9680 KB Output is correct
50 Correct 87 ms 9652 KB Output is correct
51 Correct 89 ms 9560 KB Output is correct
52 Correct 86 ms 9652 KB Output is correct
53 Correct 97 ms 9668 KB Output is correct
54 Correct 99 ms 9628 KB Output is correct
55 Correct 91 ms 9660 KB Output is correct
56 Correct 91 ms 9852 KB Output is correct
57 Correct 92 ms 9884 KB Output is correct
58 Correct 91 ms 9800 KB Output is correct
59 Correct 86 ms 9684 KB Output is correct
60 Correct 90 ms 9664 KB Output is correct
61 Correct 86 ms 9556 KB Output is correct
62 Correct 88 ms 9656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 9612 KB Output is correct
2 Correct 90 ms 9720 KB Output is correct
3 Correct 84 ms 9456 KB Output is correct
4 Correct 85 ms 9756 KB Output is correct
5 Correct 88 ms 9788 KB Output is correct
6 Correct 88 ms 9728 KB Output is correct
7 Correct 87 ms 9700 KB Output is correct
8 Correct 87 ms 9732 KB Output is correct
9 Correct 91 ms 9724 KB Output is correct
10 Correct 88 ms 9820 KB Output is correct
11 Correct 84 ms 9624 KB Output is correct
12 Correct 90 ms 9800 KB Output is correct
13 Correct 85 ms 9596 KB Output is correct
14 Correct 86 ms 9716 KB Output is correct
15 Correct 85 ms 9576 KB Output is correct
16 Correct 84 ms 9704 KB Output is correct
17 Correct 85 ms 9612 KB Output is correct
18 Correct 90 ms 9712 KB Output is correct
19 Correct 86 ms 9724 KB Output is correct
20 Correct 87 ms 9584 KB Output is correct
21 Correct 84 ms 9620 KB Output is correct
22 Correct 91 ms 9716 KB Output is correct
23 Correct 86 ms 9696 KB Output is correct
24 Correct 84 ms 9688 KB Output is correct
25 Correct 87 ms 9836 KB Output is correct
26 Correct 92 ms 9852 KB Output is correct
27 Correct 87 ms 9924 KB Output is correct
28 Correct 88 ms 9612 KB Output is correct
29 Correct 87 ms 9704 KB Output is correct
30 Correct 87 ms 9652 KB Output is correct
31 Correct 86 ms 9840 KB Output is correct
32 Correct 87 ms 9676 KB Output is correct
33 Correct 90 ms 9756 KB Output is correct
34 Correct 87 ms 9776 KB Output is correct
35 Correct 88 ms 9984 KB Output is correct
36 Correct 87 ms 9772 KB Output is correct
37 Correct 86 ms 9676 KB Output is correct
38 Correct 84 ms 9564 KB Output is correct
39 Correct 85 ms 9732 KB Output is correct
40 Correct 92 ms 9900 KB Output is correct
41 Correct 91 ms 9580 KB Output is correct
42 Correct 86 ms 9640 KB Output is correct
43 Correct 86 ms 9596 KB Output is correct
44 Correct 87 ms 9592 KB Output is correct
45 Correct 87 ms 9656 KB Output is correct
46 Correct 88 ms 9608 KB Output is correct
47 Correct 89 ms 9700 KB Output is correct
48 Correct 89 ms 9556 KB Output is correct
49 Correct 102 ms 9680 KB Output is correct
50 Correct 87 ms 9652 KB Output is correct
51 Correct 89 ms 9560 KB Output is correct
52 Correct 86 ms 9652 KB Output is correct
53 Correct 97 ms 9668 KB Output is correct
54 Correct 99 ms 9628 KB Output is correct
55 Correct 91 ms 9660 KB Output is correct
56 Correct 91 ms 9852 KB Output is correct
57 Correct 92 ms 9884 KB Output is correct
58 Correct 91 ms 9800 KB Output is correct
59 Correct 86 ms 9684 KB Output is correct
60 Correct 90 ms 9664 KB Output is correct
61 Correct 86 ms 9556 KB Output is correct
62 Correct 88 ms 9656 KB Output is correct
63 Execution timed out 1102 ms 118380 KB Time limit exceeded
64 Halted 0 ms 0 KB -