답안 #147202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147202 2019-08-28T11:52:49 Z osaaateiasavtnl 송금 (JOI19_remittance) C++14
0 / 100
2 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
const int N = 1e6 + 7;
int d[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n; cin >> n;
    queue <int> q;
    for (int i = 0; i < n; ++i) { 
        int a, b; 
        cin >> a >> b; 
        d[i] = a - b; 
        if (d[i] > 1) q.push(i); 
    }
    while (q.size()) {
        int i = q.front(); q.pop();
        if (d[i] > 1) {
            int j = (i + 1) % n;
            d[j] += d[i] >> 1;
            if (d[j] > 1) q.push(j);
            d[i] &= 1;   
        }
    }
    for (int i = 0; i < n; ++i) {
        if (d[i]) { cout << "No\n"; exit(0); }
    }
    cout << "Yes\n";
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 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 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 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 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 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 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -