답안 #170103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170103 2019-12-24T02:45:57 Z ijxjdjd 송금 (JOI19_remittance) Java 11
55 / 100
1000 ms 98156 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 < 100; 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());
        }

    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9660 KB Output is correct
2 Correct 85 ms 9720 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9588 KB Output is correct
5 Correct 85 ms 9576 KB Output is correct
6 Correct 87 ms 9792 KB Output is correct
7 Correct 92 ms 9604 KB Output is correct
8 Correct 86 ms 9976 KB Output is correct
9 Correct 89 ms 9608 KB Output is correct
10 Correct 86 ms 9748 KB Output is correct
11 Correct 86 ms 9600 KB Output is correct
12 Correct 92 ms 9736 KB Output is correct
13 Correct 85 ms 9604 KB Output is correct
14 Correct 92 ms 9708 KB Output is correct
15 Correct 86 ms 9464 KB Output is correct
16 Correct 88 ms 9848 KB Output is correct
17 Correct 86 ms 9504 KB Output is correct
18 Correct 88 ms 9644 KB Output is correct
19 Correct 88 ms 9652 KB Output is correct
20 Correct 92 ms 9668 KB Output is correct
21 Correct 91 ms 9700 KB Output is correct
22 Correct 87 ms 9540 KB Output is correct
23 Correct 89 ms 9800 KB Output is correct
24 Correct 85 ms 9776 KB Output is correct
25 Correct 88 ms 9648 KB Output is correct
26 Correct 91 ms 9640 KB Output is correct
27 Correct 87 ms 9656 KB Output is correct
28 Correct 85 ms 9728 KB Output is correct
29 Correct 86 ms 9752 KB Output is correct
30 Correct 87 ms 9744 KB Output is correct
31 Correct 88 ms 9712 KB Output is correct
32 Correct 85 ms 9736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9660 KB Output is correct
2 Correct 85 ms 9720 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9588 KB Output is correct
5 Correct 85 ms 9576 KB Output is correct
6 Correct 87 ms 9792 KB Output is correct
7 Correct 92 ms 9604 KB Output is correct
8 Correct 86 ms 9976 KB Output is correct
9 Correct 89 ms 9608 KB Output is correct
10 Correct 86 ms 9748 KB Output is correct
11 Correct 86 ms 9600 KB Output is correct
12 Correct 92 ms 9736 KB Output is correct
13 Correct 85 ms 9604 KB Output is correct
14 Correct 92 ms 9708 KB Output is correct
15 Correct 86 ms 9464 KB Output is correct
16 Correct 88 ms 9848 KB Output is correct
17 Correct 86 ms 9504 KB Output is correct
18 Correct 88 ms 9644 KB Output is correct
19 Correct 88 ms 9652 KB Output is correct
20 Correct 92 ms 9668 KB Output is correct
21 Correct 91 ms 9700 KB Output is correct
22 Correct 87 ms 9540 KB Output is correct
23 Correct 89 ms 9800 KB Output is correct
24 Correct 85 ms 9776 KB Output is correct
25 Correct 88 ms 9648 KB Output is correct
26 Correct 91 ms 9640 KB Output is correct
27 Correct 87 ms 9656 KB Output is correct
28 Correct 85 ms 9728 KB Output is correct
29 Correct 86 ms 9752 KB Output is correct
30 Correct 87 ms 9744 KB Output is correct
31 Correct 88 ms 9712 KB Output is correct
32 Correct 85 ms 9736 KB Output is correct
33 Correct 88 ms 9608 KB Output is correct
34 Correct 91 ms 9628 KB Output is correct
35 Correct 90 ms 9544 KB Output is correct
36 Correct 87 ms 9548 KB Output is correct
37 Correct 88 ms 9780 KB Output is correct
38 Correct 83 ms 9520 KB Output is correct
39 Correct 85 ms 9720 KB Output is correct
40 Correct 87 ms 9604 KB Output is correct
41 Correct 87 ms 9676 KB Output is correct
42 Correct 84 ms 9724 KB Output is correct
43 Correct 86 ms 9660 KB Output is correct
44 Correct 88 ms 9532 KB Output is correct
45 Correct 86 ms 9708 KB Output is correct
46 Correct 85 ms 9456 KB Output is correct
47 Correct 86 ms 9752 KB Output is correct
48 Correct 89 ms 9684 KB Output is correct
49 Correct 86 ms 9740 KB Output is correct
50 Correct 84 ms 9776 KB Output is correct
51 Correct 85 ms 9632 KB Output is correct
52 Correct 84 ms 9588 KB Output is correct
53 Correct 87 ms 9652 KB Output is correct
54 Correct 86 ms 9708 KB Output is correct
55 Correct 88 ms 9792 KB Output is correct
56 Correct 89 ms 9896 KB Output is correct
57 Correct 84 ms 9680 KB Output is correct
58 Correct 86 ms 9808 KB Output is correct
59 Correct 88 ms 9804 KB Output is correct
60 Correct 88 ms 9776 KB Output is correct
61 Correct 91 ms 9652 KB Output is correct
62 Correct 89 ms 9720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9660 KB Output is correct
2 Correct 85 ms 9720 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9588 KB Output is correct
5 Correct 85 ms 9576 KB Output is correct
6 Correct 87 ms 9792 KB Output is correct
7 Correct 92 ms 9604 KB Output is correct
8 Correct 86 ms 9976 KB Output is correct
9 Correct 89 ms 9608 KB Output is correct
10 Correct 86 ms 9748 KB Output is correct
11 Correct 86 ms 9600 KB Output is correct
12 Correct 92 ms 9736 KB Output is correct
13 Correct 85 ms 9604 KB Output is correct
14 Correct 92 ms 9708 KB Output is correct
15 Correct 86 ms 9464 KB Output is correct
16 Correct 88 ms 9848 KB Output is correct
17 Correct 86 ms 9504 KB Output is correct
18 Correct 88 ms 9644 KB Output is correct
19 Correct 88 ms 9652 KB Output is correct
20 Correct 92 ms 9668 KB Output is correct
21 Correct 91 ms 9700 KB Output is correct
22 Correct 87 ms 9540 KB Output is correct
23 Correct 89 ms 9800 KB Output is correct
24 Correct 85 ms 9776 KB Output is correct
25 Correct 88 ms 9648 KB Output is correct
26 Correct 91 ms 9640 KB Output is correct
27 Correct 87 ms 9656 KB Output is correct
28 Correct 85 ms 9728 KB Output is correct
29 Correct 86 ms 9752 KB Output is correct
30 Correct 87 ms 9744 KB Output is correct
31 Correct 88 ms 9712 KB Output is correct
32 Correct 85 ms 9736 KB Output is correct
33 Correct 88 ms 9608 KB Output is correct
34 Correct 91 ms 9628 KB Output is correct
35 Correct 90 ms 9544 KB Output is correct
36 Correct 87 ms 9548 KB Output is correct
37 Correct 88 ms 9780 KB Output is correct
38 Correct 83 ms 9520 KB Output is correct
39 Correct 85 ms 9720 KB Output is correct
40 Correct 87 ms 9604 KB Output is correct
41 Correct 87 ms 9676 KB Output is correct
42 Correct 84 ms 9724 KB Output is correct
43 Correct 86 ms 9660 KB Output is correct
44 Correct 88 ms 9532 KB Output is correct
45 Correct 86 ms 9708 KB Output is correct
46 Correct 85 ms 9456 KB Output is correct
47 Correct 86 ms 9752 KB Output is correct
48 Correct 89 ms 9684 KB Output is correct
49 Correct 86 ms 9740 KB Output is correct
50 Correct 84 ms 9776 KB Output is correct
51 Correct 85 ms 9632 KB Output is correct
52 Correct 84 ms 9588 KB Output is correct
53 Correct 87 ms 9652 KB Output is correct
54 Correct 86 ms 9708 KB Output is correct
55 Correct 88 ms 9792 KB Output is correct
56 Correct 89 ms 9896 KB Output is correct
57 Correct 84 ms 9680 KB Output is correct
58 Correct 86 ms 9808 KB Output is correct
59 Correct 88 ms 9804 KB Output is correct
60 Correct 88 ms 9776 KB Output is correct
61 Correct 91 ms 9652 KB Output is correct
62 Correct 89 ms 9720 KB Output is correct
63 Execution timed out 1085 ms 98156 KB Time limit exceeded
64 Halted 0 ms 0 KB -