# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
934700 | 2024-02-27T20:09:15 Z | haxorman | 이상한 기계 (APIO19_strange_device) | C++14 | 329 ms | 53824 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int mxN = 1e6 + 7; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a, b; cin >> n >> a >> b; __int128 p = a; p *= b; p /= __gcd(a, b+1); int ans = 0; vector<pair<int,int>> ranges; for (int i = 0; i < n; ++i) { int l, r; cin >> l >> r; if (r - l + 1 >= p) { ans = p; } l %= p, r %= p; if (r < l) { ranges.push_back({l, p-1}); ranges.push_back({0, r}); } else { ranges.push_back({l, r}); } } if (ans == p) { cout << ans << "\n"; exit(0); } sort(ranges.begin(), ranges.end()); auto [l, r] = ranges[0]; for (int i = 1; i < ranges.size(); ++i) { auto [lb, rb] = ranges[i]; if (lb <= r) { rb = r; } else { ans += r - l + 1; l = lb, r = rb; } } ans += r - l + 1; cout << ans << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 3 ms | 736 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 291 ms | 17328 KB | Output is correct |
3 | Correct | 299 ms | 53168 KB | Output is correct |
4 | Correct | 289 ms | 53824 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 291 ms | 17328 KB | Output is correct |
3 | Correct | 299 ms | 53168 KB | Output is correct |
4 | Correct | 289 ms | 53824 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 301 ms | 53616 KB | Output is correct |
7 | Correct | 310 ms | 53312 KB | Output is correct |
8 | Correct | 294 ms | 53040 KB | Output is correct |
9 | Correct | 329 ms | 53108 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 291 ms | 17328 KB | Output is correct |
3 | Correct | 299 ms | 53168 KB | Output is correct |
4 | Correct | 289 ms | 53824 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 30 ms | 5724 KB | Output is correct |
7 | Correct | 31 ms | 5844 KB | Output is correct |
8 | Incorrect | 29 ms | 5844 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 32 ms | 4312 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 3 ms | 736 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |