제출 #1148947

#제출 시각아이디문제언어결과실행 시간메모리
1148947blackslex이상한 기계 (APIO19_strange_device)C++20
10 / 100
298 ms16940 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; int n; ll a, b, x, y; int main() { scanf("%d %lld %lld", &n, &a, &b); ll m = (a > 1e18 / b ? 1e18 : 1LL * a * b); vector<pii> c; auto add = [&] (ll l, ll r) { l %= m; r %= m; if (l > r) { c.emplace_back(l, m - 1); c.emplace_back(0, r); } else { c.emplace_back(l, r); } }; for (int i = 0; i < n; i++) { scanf("%lld %lld", &x, &y); if (y - x + 1 >= m) add(0, m - 1); else add(x, y); } sort(c.begin(), c.end()); ll ans = 0, st = 0, ed = -1; for (auto &[x, y]: c) { if (x <= ed) ed = max(ed, y); else { ans += ed - st + 1; st = x; ed = y; } } ans += ed - st + 1; printf("%lld", ans); }

컴파일 시 표준 에러 (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, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...