# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1260719 | mingga | Remittance (JOI19_remittance) | C++20 | 0 ms | 328 KiB |
// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 1e6 + 7;
int n, a[N], b[N], nxt[N];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n;
int tota = 0, totb = 0;
for(int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
tota += a[i];
totb += b[i];
nxt[i] = i + 1;
if(i == n) nxt[i] = 1;
}
if(tota < totb) cout << "No";
else {
for(int t = 0; t < 80; t++) {
for(int i = 1; i <= n; i++) {
if(a[i] > b[i] and (a[i] - b[i]) % 2 == 0) {
int t = (a[i] - b[i] + 1) / 2;
a[i] -= 2 * t;
a[nxt[i]] += t;
}
}
}
bool ok = 1;
for(int i = 1; i <= n; i++) {
if(a[i] != b[i]) {
ok = 0;
break;
}
}
if(ok) cout << "Yes";
else cout << "No";
}
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (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... |