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 endl '\n'
typedef long long ll;
const int MAX_N = 1e6 + 10;
int n;
ll a[MAX_N], b[MAX_N];
void solve()
{
std::cin >> n;
for (int i = 1; i <= n; i ++)
std::cin >> a[i] >> b[i];
while(true)
{
bool done = true;
for (int i = 1; i <= n; i ++)
{
int nxt = i + 1;
if (i == n)
nxt = 1;
ll left = a[i] - b[i];
if (left < 0)
left = 0;
left /= 2;
a[i] -= left * 2;
a[nxt] += left;
if (left != 0)
done = false;
}
if (done)
break;
}
bool fine = true;
for (int i = 1; i <= n; i ++)
if (a[i] != b[i])
fine = false;
if (fine)
std::cout << "Yes" << endl;
else
std::cout << "No" << endl;
}
void speed()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
}
int main()
{
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |