Submission #162756

#TimeUsernameProblemLanguageResultExecution timeMemory
162756SwanRemittance (JOI19_remittance)C++14
0 / 100
2 ms380 KiB
#include <bits/stdc++.h> #define stop system("pause") #define INP freopen("input.txt","r",stdin) #define OUTP freopen("output.txt","w",stdout) #define double long double #define int long long using namespace std; typedef long long ll; vector<pair<int,int> > v; bool check(){ for(int i(0); i < v.size();i++){ if(v[i].first != v[i].second)return 0; } return 1; } bool solve(){ for(int i(0); i < v.size();i++){ int to = (i+1)%v.size(); int can = v[i].first-v[i].second; if(can <= 0)continue; can/=2; if(can == 0)continue; can = 1; v[to].first+=can; v[i].first-=2*can; //cerr << i+1 << ' ' << can << endl; return 1; } return 0; } main() { ios_base::sync_with_stdio(0); int n; cin >> n; for(int i(0); i < n;i++){ int a,b; cin >> a >> b; v.push_back({a,b}); } //cerr << '\n'; while(1){ bool f = solve(); if(!f)break; } if(!check())cout << "No"; else cout << "Yes"; return 0; } /* 3 1 3 3 4 6 3 7 9 3 */

Compilation message (stderr)

remittance.cpp: In function 'bool check()':
remittance.cpp:14:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < v.size();i++){
                   ~~^~~~~~~~~~
remittance.cpp: In function 'bool solve()':
remittance.cpp:21:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i(0); i < v.size();i++){
                   ~~^~~~~~~~~~
remittance.cpp: At global scope:
remittance.cpp:36:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...