제출 #522789

#제출 시각아이디문제언어결과실행 시간메모리
522789CPSC송금 (JOI19_remittance)C++14
0 / 100
1 ms300 KiB
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
const int N = 3e5 + 5;
int a[N],b[N],val,ff,n;
main() {
    cin>>n;
    for (int i = 1; i <= n; i++) {
        cin>>a[i]>>b[i];
    }
    while (true) {
        ff = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] > b[i]) {
                val = (a[i] - b[i] + 1) / 2; val *= 2;
                if (i == n) {
                   
                    a[i] -= val;
                    a[1] += val/2;
                } else a[i] -= val, a[i + 1] += val / 2;
                ff = 1;
            }
        }
        if (!ff) break;
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] != b[i]) {
            cout<<"No"<<endl; exit(0);
        }
    }
    cout<<"Yes"<<endl;
}

컴파일 시 표준 에러 (stderr) 메시지

remittance.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...