Submission #1028788

#TimeUsernameProblemLanguageResultExecution timeMemory
1028788underwaterkillerwhaleRemittance (JOI19_remittance)C++17
0 / 100
1100 ms396 KiB
#include <bits/stdc++.h> #define se second #define fs first #define mp make_pair #define pb push_back #define ll long long #define ii pair<ll,ll> #define ld long double #define SZ(v) (int)v.size() #define ALL(v) v.begin(), v.end() #define bit(msk, i) ((msk >> i) & 1) #define iter(id, v) for(auto id : v) #define rep(i,m,n) for(int i=(m); i<=(n); i++) #define reb(i,m,n) for(int i=(m); i>=(n); i--) using namespace std; mt19937_64 rd(chrono :: steady_clock :: now().time_since_epoch().count()); ll Rand(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rd); } const int N = 2e5 + 7; const int Mod = 1e9 + 7; const int szBL = 320; const int INF = 1e9; const int BASE = 1337; int n; pair<int,int> a[N]; void solution () { cin >> n; rep (i, 1, n) cin >> a[i].fs >> a[i].se; queue<int> Q; rep (i, 1, n) { if (a[i].fs > a[i].se) Q.push(i); } while (!Q.empty()) { int u = Q.front(); Q.pop(); int nxt = 1 + u % n; a[nxt].fs += (a[u].fs - a[u].se) / 2; a[u].fs -= (a[u].fs - a[u].se) / 2 * 2; if (a[nxt].fs > a[nxt].se) Q.push(nxt); } rep (i, 1, n) if (a[i].fs != a[i].se) { cout <<"No\n"; return; } cout <<"Yes\n"; } #define file(name) freopen(name".inp", "r", stdin); \ freopen(name".out", "w", stdout); int main () { // file("c"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll num_Test = 1; // cin >> num_Test; while(num_Test--) solution(); } /* nếu mình nghĩ sẽ thay đổi định nghĩa, kiểu dữ liệu của hàm hay mảng j thì mình phải nghĩ xem nó sẽ ảnh hưởng đến các phần nào */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...