답안 #170100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170100 2019-12-24T02:42:32 Z ijxjdjd 송금 (JOI19_remittance) Java 11
0 / 100
91 ms 9828 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++) {
                    A[i] += last;
                    if (A[i] > B[i]) {
                        if (A[i] - ((A[i] - B[i] + 1) / 2) < 0) {
                            continue;
                        }
                        last = ((A[i] - B[i]) + 1) / 2;
                        A[i] -= last * 2;
                    } else {
                        last = 0;
                    }
                }
//            }
            }
            A[0] += 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 9588 KB Output is correct
2 Correct 85 ms 9792 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9712 KB Output is correct
5 Correct 86 ms 9708 KB Output is correct
6 Correct 89 ms 9700 KB Output is correct
7 Correct 82 ms 9548 KB Output is correct
8 Correct 91 ms 9600 KB Output is correct
9 Correct 86 ms 9724 KB Output is correct
10 Correct 85 ms 9716 KB Output is correct
11 Correct 86 ms 9688 KB Output is correct
12 Correct 84 ms 9700 KB Output is correct
13 Correct 88 ms 9828 KB Output is correct
14 Correct 84 ms 9520 KB Output is correct
15 Correct 87 ms 9684 KB Output is correct
16 Correct 86 ms 9780 KB Output is correct
17 Correct 85 ms 9712 KB Output is correct
18 Correct 86 ms 9628 KB Output is correct
19 Correct 88 ms 9600 KB Output is correct
20 Incorrect 84 ms 9648 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9588 KB Output is correct
2 Correct 85 ms 9792 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9712 KB Output is correct
5 Correct 86 ms 9708 KB Output is correct
6 Correct 89 ms 9700 KB Output is correct
7 Correct 82 ms 9548 KB Output is correct
8 Correct 91 ms 9600 KB Output is correct
9 Correct 86 ms 9724 KB Output is correct
10 Correct 85 ms 9716 KB Output is correct
11 Correct 86 ms 9688 KB Output is correct
12 Correct 84 ms 9700 KB Output is correct
13 Correct 88 ms 9828 KB Output is correct
14 Correct 84 ms 9520 KB Output is correct
15 Correct 87 ms 9684 KB Output is correct
16 Correct 86 ms 9780 KB Output is correct
17 Correct 85 ms 9712 KB Output is correct
18 Correct 86 ms 9628 KB Output is correct
19 Correct 88 ms 9600 KB Output is correct
20 Incorrect 84 ms 9648 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 9588 KB Output is correct
2 Correct 85 ms 9792 KB Output is correct
3 Correct 85 ms 9700 KB Output is correct
4 Correct 85 ms 9712 KB Output is correct
5 Correct 86 ms 9708 KB Output is correct
6 Correct 89 ms 9700 KB Output is correct
7 Correct 82 ms 9548 KB Output is correct
8 Correct 91 ms 9600 KB Output is correct
9 Correct 86 ms 9724 KB Output is correct
10 Correct 85 ms 9716 KB Output is correct
11 Correct 86 ms 9688 KB Output is correct
12 Correct 84 ms 9700 KB Output is correct
13 Correct 88 ms 9828 KB Output is correct
14 Correct 84 ms 9520 KB Output is correct
15 Correct 87 ms 9684 KB Output is correct
16 Correct 86 ms 9780 KB Output is correct
17 Correct 85 ms 9712 KB Output is correct
18 Correct 86 ms 9628 KB Output is correct
19 Correct 88 ms 9600 KB Output is correct
20 Incorrect 84 ms 9648 KB Output isn't correct
21 Halted 0 ms 0 KB -