이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define all(x) x.begin(), x.end()
#define sp(x) setprecision(x) << fixed
typedef long double db;
const int N = 1e6 + 5;
const int inf = 1e9;
bool solve() {
int n; cin >> n;
vector<int> a(n + 1), b(n + 1);
rep(i, 1, n) cin >> a[i] >> b[i];
bool change = 1;
while (change) {
change = 0;
// rep(i, 1, n) cout << a[i] << ' ' << b[i] << '\n';
// cout << '\n';
rep(i, 1, n) {
int nx = (i == n) ? 1 : i + 1;
int add = (a[i] - b[i]) / 2;
if (add > 0) {
// cout<<"i,add="<<i<<' '<<add<<'\n';
a[nx] += add;
a[i] -= 2 * add;
change = 1;
}
}
}
rep(i, 1, n) if (a[i] != b[i]) return false;
return true;
}
main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cout << (solve() ? "Yes" : "No");
}
컴파일 시 표준 에러 (stderr) 메시지
remittance.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
45 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |