Submission #946313

#TimeUsernameProblemLanguageResultExecution timeMemory
946313hariaakas646Remittance (JOI19_remittance)C++14
0 / 100
1 ms436 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, l, r) for(int i=l; i<r; i++) #define frange(i, l) forr(i, 0, l) #define pb push_back #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef long long lli; typedef vector<vi> vvi; typedef vector<lli> vll; typedef vector<bool> vb; typedef set<int> seti; typedef multiset<int> mseti; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } int main() { // usaco(); int n; scd(n); vii vec(n); priority_queue<pair<int, int>> pq; frange(i, n) { scd(vec[i].f); scd(vec[i].s); if(vec[i].s < vec[i].f && vec[i].f != 1) pq.push(mp(vec[i].f - vec[i].s, i)); } while(pq.size()) { auto p = pq.top(); pq.pop(); int i = p.s; if(p.f != vec[i].f - vec[i].s) continue; if(p.f % 2) { vec[i].f = vec[i].s - 1; vec[(i+1)%n].f = vec[(i+1)%n].f + ((p.f+1)/2); } else { vec[i].f = vec[i].s; vec[(i+1)%n].f = vec[(i+1)%n].f + (p.f/2); } int id = (i+1)%n; if(vec[id].s < vec[id].f && vec[id].f != 1) pq.push(mp(vec[id].f - vec[id].s, id)); } bool done = true; frange(i, n) { if(vec[i].f != vec[i].s) done = false; } if(done) printf("Yes\n"); else printf("No\n"); }

Compilation message (stderr)

remittance.cpp: In function 'void usaco()':
remittance.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp: In function 'int main()':
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:34:5: note: in expansion of macro 'scd'
   34 |     scd(n);
      |     ^~~
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:38:9: note: in expansion of macro 'scd'
   38 |         scd(vec[i].f);
      |         ^~~
remittance.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
remittance.cpp:39:9: note: in expansion of macro 'scd'
   39 |         scd(vec[i].s);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...