Submission #1102154

#TimeUsernameProblemLanguageResultExecution timeMemory
1102154ro9669Remittance (JOI19_remittance)C++17
100 / 100
642 ms36476 KiB
#include <bits/stdc++.h> #define fi first #define se second #define all(v) v.begin() , v.end() #define sz(v) int(v.size()) #define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin()); using namespace std; typedef long long ll; typedef pair<int , int> ii; typedef pair<long long , int> lli; const int maxN = int(1e6)+7; int n; ll a[maxN] , b[maxN]; bool check(){ for (int i = 0 ; i < n ; i++){ if (a[i] != b[i]) return 0; } return 1; } void solve(){ cin >> n; for (int i = 0 ; i < n ; i++){ cin >> a[i] >> b[i]; } for (int t = 0 ; t < 100 ; t++){ for (int i = 0 ; i < n ; i++){ if (a[i] >= b[i]){ ll x = (a[i] - b[i]) / 2; a[i] -= 2 * x; a[(i + 1) % n] += x; } } } for (int i = 0 ; i < n ; i++){ if (a[i] < b[i]){ cout << "No\n"; return; } } if (check()){ cout << "Yes\n"; return; } bool ok = 0; for (int i = 0 ; i < n ; i++){ if (a[i] == b[i]){ cout << "No\n"; return; } if (a[i] > 1) ok = 1; } if (ok) cout << "Yes\n"; else cout << "No\n"; } #define name "A" int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(name".INP" , "r")){ freopen(name".INP" , "r" , stdin); freopen(name".OUT" , "w" , stdout); } int t = 1; //cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(name".INP" , "r" , stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(name".OUT" , "w" , stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...