Submission #444237

#TimeUsernameProblemLanguageResultExecution timeMemory
444237qwerasdfzxclStrange Device (APIO19_strange_device)C++14
15 / 100
586 ms25252 KiB
#include <bits/stdc++.h> typedef __int128_t l128; typedef long long ll; using namespace std; int main(){ int n; ll x, y; scanf("%d %lld %lld", &n, &x, &y); l128 t = y; t *= x/__gcd(x, y+1); ll MOD = (ll)1e18+10; if (t<=(ll)1e18+10) MOD = t; //printf("%lld\n", MOD); vector<pair<ll, ll>> ran; for (int i=0;i<n;i++){ ll tmp1, tmp2; scanf("%lld %lld", &tmp1, &tmp2); if (tmp2-tmp1+1>=MOD) {printf("%lld\n", MOD); return 0;} tmp2++; tmp1 %= MOD, tmp2 %= MOD; if (tmp2<tmp1){ ran.emplace_back(tmp1, MOD); ran.emplace_back(0, tmp2); } else ran.emplace_back(tmp1, tmp2); } sort(ran.begin(), ran.end()); ll ans = 0; pair<ll, ll> cur = {0, 0}; n = ran.size(); for (int i=0;i<n;i++){ if (cur.first<=ran[i].first && ran[i].first<=cur.second){ ans += ran[i].second-cur.second; cur.second = ran[i].second; } else{ ans += ran[i].second-ran[i].first; cur = ran[i]; } } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %lld %lld", &n, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld %lld", &tmp1, &tmp2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...