답안 #187334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
187334 2020-01-12T18:20:09 Z wet_water 송금 (JOI19_remittance) C++14
0 / 100
2 ms 380 KB
#include <iostream>
#include <fstream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <string.h>
#include <math.h>
#include <set>

#define MAX_N 1000005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;

int A[MAX_N], B[MAX_N];
int N;

void solve() {
    cin >> N;
    
    for (int i = 0; i < N; i ++) {
        cin >> A[i] >> B[i];
    }
    
    int carry;
    for (int ii = 0; ii < 100; ii ++) {
        for (int i = 0; i < N; i ++) {
            if (A[i] > B[i]) {
                carry = ((A[i] - B[i]) / 2);
                A[i] -= ((A[i] - B[i]) / 2) * 2;
                A[(i + 1) % N] += carry;
            }
        }
    }
    
    bool flag = true;
    for (int i = 0; i < N; i ++) {
        flag = (flag && (A[i] == B[i]));
    }
    
    if (flag)
        cout << ("Yes") << endl;
    else {
        bool flag2 = true;
    
        for (int i = 0; i < N; i ++)
            flag2 = (flag2 && (A[i] - 1 == B[i]));
            
        cout << (flag2 ? "Yes" : "No") << endl;
    }
    
    return;
}
 
int main() {
    int T;
    T = 1;
    
    for (int i = 0; i < T; i ++) {
        solve();
    }
 
    return (0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 0 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Incorrect 2 ms 376 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 0 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Incorrect 2 ms 376 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 0 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Incorrect 2 ms 376 KB Output isn't correct
21 Halted 0 ms 0 KB -