# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
200524 | 2020-02-07T06:07:23 Z | HellAngel | 송금 (JOI19_remittance) | C++14 | 7 ms | 380 KB |
#include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 1000007; int a[maxn], b[maxn], n; struct cmp { bool operator()(const pair<int, int> &a, const pair<int, int> &b) { if(a.first == b.first) return ::a[a.second] < ::a[b.second]; return a.first < b.first; } }; set<pair<int, int>, cmp> st; void AnsNo() { cout << "No"; exit(0); } void AnsYes() { cout << "Yes"; exit(0); } void Change(int pos, int val) { int npos = (pos + 1) % n; st.erase({a[pos] - b[pos], pos}); st.erase({a[npos] - b[npos], npos}); a[pos] -= 2 * val; if(a[pos] < 0) AnsNo(); a[npos] += val; st.insert({a[pos] - b[pos], pos}); st.insert({a[npos] - b[npos], npos}); } int32_t main() { auto start = chrono::steady_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin); cin >> n; for(int i = 0; i < n; i++) cin >> a[i] >> b[i], st.insert({a[i] - b[i], i}); while(true) { if(st.rbegin()->first < 0) AnsNo(); if(st.rbegin()->first == 0) { if(st.begin()->first < 0) AnsNo(); else AnsYes(); } Change(st.rbegin()->second, max(st.rbegin()->first / 2, 1ll)); } auto finish = chrono::steady_clock::now(); cerr << '\n'<< chrono::duration_cast<chrono::milliseconds>(finish - start).count(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Incorrect | 5 ms | 380 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Incorrect | 5 ms | 380 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Incorrect | 5 ms | 380 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |