답안 #922792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
922792 2024-02-06T06:36:55 Z phoenix0423 송금 (JOI19_remittance) C++17
0 / 100
1 ms 348 KB
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> pll;
    #define fastio ios::sync_with_stdio(false), cin.tie(0)
    #define pb push_back
    #define eb emplace_back
    #define f first
    #define s second
    #define int long long
    const int INF = 1e12;

    signed main(void){
        fastio;
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i = 0; i < n; i++){
            int x, y;
            cin>>x>>y;
            a[i] = x - y;
        }
        for(int i = 0; i < n; i++){
            if(a[i] > 0 && a[i] % 2){
                int nd = 2;
                int id = (i - 1 + n) % n;
                while(id != i && a[id] < nd && nd < INF){
                    if(a[id] > 0) nd -= a[id], a[id] = 0;
                    nd *= 2;
                    id = (id - 1 + n) % n;
                }
                if(a[id] < nd){
                    cout<<"No\n";
                    return 0;
                }
                a[id] -= nd;
                a[i] ++;
            }
        }
        for(int i = 0; i < n; i++){
            if(a[i] < 0){
                int nd = - a[i] * 2;
                int id = (i - 1 + n) % n;
                while(id != i && a[id] < nd && nd < INF){
                    if(a[id] > 0) nd -= a[id], a[id] = 0;
                    nd *= 2;
                    id = (id - 1 + n) % n;
                }
                if(a[id] < nd){
                    cout<<"No\n";
                    return 0;
                }
                a[id] -= nd;
                a[i] = 0;
            }
        }
        for(auto x : a){
            if(x){
                cout<<"No\n";
                return 0;
            }
        }
        cout<<"Yes\n";
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -