Submission #138029

#TimeUsernameProblemLanguageResultExecution timeMemory
138029qkxwsmRemittance (JOI19_remittance)C++14
100 / 100
628 ms9916 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() #define INF 1000000007 #define LLINF 2696969696969696969ll #define MAXN 1000013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N; int A[MAXN], B[MAXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; FOR(i, 0, N) { cin >> A[i] >> B[i]; } //ok i think we can get away with trying to send stuff in batches of big FORD(i, 30, 1) { FOR(k, 0, 3) { FOR(j, 0, N) { if (A[j] >= B[j] + (1 << i)) { A[j] -= (1 << i); A[(j == N - 1 ? 0 : j + 1)] += (1 << (i - 1)); } } } // cerr << "HAVE:"; // FOR(j, 0, N) // { // cerr << ' ' << A[j]; // } // cerr << endl; } FOR(k, 0, 3) { FOR(i, 0, N) { if (A[i] >= 2 && A[i] > B[i]) { A[i] -= 2; A[(i == N - 1 ? 0 : i + 1)]++; } } } FOR(i, 0, N) { if (A[i] != B[i]) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; //basically you're just checking if these two things are identical among these rules }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...