제출 #436580

#제출 시각아이디문제언어결과실행 시간메모리
436580dariasc송금 (JOI19_remittance)C++14
0 / 100
1 ms292 KiB
#include <bits/stdc++.h> using namespace std; int bad() { cout << "No\n"; return 0; } int main() { int n; cin >> n; int a[n], b[n]; int peak = -1; int peak_index = -1; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (a[i] > peak) { peak = a[i]; peak_index = i; } } rotate(a, a + peak_index, a + n); rotate(b, b + peak_index, b + n); for (int i = 0; i < n-1; i++) { if (a[i] < b[i]) { return bad(); } int diff = a[i] - b[i]; if (diff % 2 == 1) { return bad(); } a[i] -= diff; a[i+1] += diff/2; } if (a[n-1] == b[n-1]) { cout << "Yes\n"; } else { return bad(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...