제출 #538910

#제출 시각아이디문제언어결과실행 시간메모리
538910Monarchuwu송금 (JOI19_remittance)C++17
100 / 100
667 ms40372 KiB
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N = 1e6 + 9; int n, nxt[N]; ll a[N], b[N]; bool check() { ll ma = *max_element(a + 1, a + n + 1); ll mi = *min_element(a + 1, a + n + 1); if (ma != mi) return false; if (ma == 0) return true; if (ma == 1) return *max_element(b + 1, b + n + 1) > 0; return false; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i], a[i] -= b[i], nxt[i] = i % n + 1; for (int times = 0; times * n < 1e8; ++times) for (int i = 1; i <= n; ++i) if (a[i] > 0) { ll tmp = a[i] >> 1; a[i] -= tmp << 1; a[nxt[i]] += tmp; } cout << (check() ? "Yes\n" : "No\n"); } /** /\_/\ * (= ._.) * / >0 \>1 **/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...