This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
cerr << to_string(h);
if(sizeof ...(t)) cerr << ", ";
DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif
const int INF = 1e9 + 7;
signed main()
{
IO_OP;
int n;
cin >> n;
V<ll> a(n), b(n);
for(int i = 0; i < n; i++)
cin >> a[i] >> b[i];
while(true) {
bool change = false;
for(int i = 0; i < n; i++) {
ll move = 0;
if(a[i] > b[i]) {
if(b[i] == 0) move = a[i] / 2;
else move = (a[i] - b[i] + 1) / 2;
}
a[i] -= move * 2;
a[(i + 1) % n] += move;
if(move) change = true;
}
if(!change) break;
}
cout << (a == b ? "Yes" : "No") << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |