Submission #331034

#TimeUsernameProblemLanguageResultExecution timeMemory
331034CodeTiger927Remittance (JOI19_remittance)C++14
0 / 100
1 ms364 KiB
using namespace std; #include <iostream> #define MAXN 100005 int N; long long arrA[MAXN],arrB[MAXN],pref[MAXN]; int main() { cin >> N; int record = -1; for(int i = 0;i < N;++i) { cin >> arrA[i] >> arrB[i]; pref[i] = arrA[i] - arrB[i]; if(i > 0) pref[i] += pref[i - 1]; if(record == -1 || pref[record] < pref[i]) { record = i; } } int curSum = 0; for(int i = 0;i < N;++i) { int cur = (record + i) % N; if(arrA[cur] - arrB[cur] + curSum < 0 || (arrA[cur] - arrB[cur] + curSum) % 2) { cout << "No" << endl; return 0; } curSum += arrA[cur] - arrB[cur]; curSum = curSum / 2; curSum = max(curSum,0); } cout << "Yes" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...