| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1305072 | hoa208 | Remittance (JOI19_remittance) | C++20 | 13 ms | 580 KiB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
//--------------------------------------------------------------------
const ll N = 1e6 + 10;
ll a[N], b[N];
ll n;
void hbmt() {
cin >> n;
FOR(i, 1, n) {
cin >> a[i] >> b[i];
}
ll cnt = 10000000;
ll u = 1;
while(cnt--) {
ll c = b[u] - a[u];
ll v = u == 1 ? v = n : v = u - 1;
if(c <= 0) {
u = v;
continue;
}
a[u] = b[u];
if(v == 0) {
v = n;
}
a[v] -= 2 * c;
u = v;
}
cnt = 0;
bool nope1 = 0;
FOR(i, 1, n) {
if(a[i] != b[i]) {
nope1 = 1;
}
if(a[i] > b[i] ) {
cnt++;
}
}
if(cnt == n) {
cout << "Yes\n";
}
else if(nope1) {
cout << "No\n";
}
else
cout << "Yes\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
#define NAME "hbmt"
if(fopen(NAME".inp", "r")) {
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
//int t;cin>>t;while(t--)
hbmt();
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
