Submission #746263

#TimeUsernameProblemLanguageResultExecution timeMemory
746263nguyentunglamRemittance (JOI19_remittance)C++17
100 / 100
608 ms40424 KiB
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 1e6 + 10; int nxt[N]; long long a[N], b[N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i], nxt[i] = i + 1; nxt[n] = 1; if (n == 1) return cout << "Yes", 0; for(int loop = 1; loop <= 100; loop++) { for(int i = 1; i <= n; i++) { if (a[i] > b[i]) { long long delta = a[i] - b[i]; if (delta % 2) { if (a[i] >= delta + 1) delta++; else delta--; } delta >>= 1; a[i] -= delta << 1; a[nxt[i]] += delta; } } } bool ok = 1; for(int i = 1; i <= n; i++) ok &= a[i] == b[i]; cout << (ok ? "Yes" : "No"); }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...