# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
361921 | 2021-02-01T07:01:37 Z | parsabahrami | 이상한 기계 (APIO19_strange_device) | C++17 | 768 ms | 63212 KB |
// Call my Name and Save me from The Dark #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 1e6 + 10; ll A, B; int n; set<pii> st; int main() { scanf("%d%lld%lld", &n, &A, &B); ll tof = A / __gcd(A, B + 1), blk; if ((ll) 1e18 / B > tof) blk = (ll) 1e18 + 1; else blk = tof * B; for (int i = 1; i <= n; i++) { ll l, r; scanf("%lld%lld", &l, &r); if (r - l + 1 >= blk) return !printf("%lld\n", blk); if (l % blk <= r % blk) st.insert({l % blk, -(r % blk)}); else st.insert({0, -(r % blk)}), st.insert({l % blk, -(blk - 1)}); } ll mx = -1, ret = 0; for (pii x : st) { ret += max(0ll, -x.S - max(mx + 1, x.F) + 1); mx = max(mx, -x.S); } printf("%lld\n", ret); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 7 ms | 1260 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 768 ms | 63212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 768 ms | 63212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 768 ms | 63212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Incorrect | 70 ms | 7788 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 7 ms | 1260 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |