Submission #496086

#TimeUsernameProblemLanguageResultExecution timeMemory
496086khoabrightRemittance (JOI19_remittance)C++17
0 / 100
1 ms204 KiB
#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"); }

Compilation message (stderr)

remittance.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...