# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
372470 | 2021-02-28T09:41:38 Z | hivakarami | 이상한 기계 (APIO19_strange_device) | C++14 | 464 ms | 27928 KB |
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define f first #define s second const int N = 1e6 + 100; const ll mod = 1e9 + 7; const ll inf = 1e18 + 10; vector<pair<ll, ll>> v; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; ll a, b; cin >> n >> a >> b; ll k = a / __gcd(a, b+1); if(k > inf/b) k = inf; else k *= b; while(n--) { ll l, r; cin >> l >> r; if(r - l + 1 >= k) { cout << k << endl; return 0; } l = l%k; r = r%k; if(l <= r) { v.push_back({l, r}); } else { v.push_back({l, k-1}); v.push_back({0, r}); } } sort(v.begin(), v.end()); ll ans = 0, mx = -1; for(int i = 0; i < v.size(); i++) { ll l = v[i].f, r = v[i].s; if(l > mx) ans += r - l + 1; else if(r >= mx) ans = r - mx; mx = max(mx, r); } cout << ans << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 5 ms | 1132 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 364 KB | Output is correct |
2 | Incorrect | 464 ms | 27928 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 464 ms | 27928 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 464 ms | 27928 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 49 ms | 5732 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 5 ms | 1132 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |