제출 #444240

#제출 시각아이디문제언어결과실행 시간메모리
444240qwerasdfzxcl이상한 기계 (APIO19_strange_device)C++14
100 / 100
666 ms25456 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 += max(ran[i].second-cur.second, 0LL); cur.second = max(cur.second, ran[i].second); } else{ ans += ran[i].second-ran[i].first; cur = ran[i]; } } printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (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...