이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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] && !(A[i] == 1 && B[i] == 0)) {
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());
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |