답안 #655084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655084 2022-11-03T01:55:16 Z yclin 송금 (JOI19_remittance) C++14
0 / 100
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
int a[1000010];
signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,x,y,start;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        a[i]=x-y;
        if(a[i]>0 && !(a[i]&1)){
            start=i;
        }
    }
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        int f=q.front();
        q.pop();
        int temp=a[f];
        int now=f;
        while(temp!=0){
            a[now]-=temp;
            temp/=2;
            now=(now+1)%n;
            a[now]+=temp;
            if(a[now]<=0) temp=0;
            else if(a[now]&1){
                temp=a[now]-1;
            }
            else{
                temp=a[now];
            }
            if(temp==0){
                for(int i=0;i<n;i++){
                    if(a[i]>0 && a[i]&1){
                        start=i;
                    }
                    q.push(start);
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=0){
            cout<<"No";
        }
    }
    cout<<"Yes";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -