Submission #486177

#TimeUsernameProblemLanguageResultExecution timeMemory
486177idasRemittance (JOI19_remittance)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr) #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define F first #define S second #define PB push_back #define MP make_pair #define sz(x) int((x).size()) using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; typedef map<int, int> mii; typedef vector<int> vi; typedef long double ld; typedef long long ll; const int INF=1e9, MOD=1e9+7, mod=998244353; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e6+10; ll n, a[N], b[N]; int main() { setIO(); cin >> n; FOR(i, 0, n) { cin >> a[i] >> b[i]; } set<int> st; FOR(i, 0, n) { if(a[i]-b[i]>1) st.insert(i); } bool going=true; while(going){ going=false; for(auto x : st){ ll neg=a[x]-b[x]; neg/=2; a[x]-=neg*2; int nxt=(x+1)%n; a[nxt]+=neg; if(a[nxt]-b[nxt]>1){ st.insert(nxt); going=true; } if(a[x]-b[x]>1){ st.insert(x); going=true; } } } FOR(i, 0, n) { if(a[i]!=b[i]){ cout << "No"; return 0; } } cout << "Yes"; }

Compilation message (stderr)

remittance.cpp: In function 'void setIO(std::string)':
remittance.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...