# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
370781 | 2021-02-24T15:20:03 Z | cpp219 | 이상한 기계 (APIO19_strange_device) | C++14 | 531 ms | 31932 KB |
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 1e6 + 3; const ll inf = 1e9 + 7; LL a[N]; ll n,A,B,q,total; vector<LL> v; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>A>>B; q = A/__gcd(B + 1,A); total = q * B; for (ll i = 1;i <= n;i++){ cin>>a[i].fs>>a[i].sc; a[i].fs %= total; a[i].sc %= total; if (a[i].fs <= a[i].sc) v.push_back(a[i]); else{ v.push_back({0,a[i].sc}); v.push_back({a[i].fs,total - 1}); } } sort(v.begin(),v.end()); ll mx = -inf,ans = 0; for (auto i : v){ if (i.sc <= mx) continue; if (i.fs > mx) ans += i.sc - i.fs + 1; else ans += max(0ll,i.sc - mx); mx = max(mx,i.sc); } cout<<ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 5 ms | 876 KB | Output is correct |
3 | Correct | 5 ms | 876 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 5 ms | 876 KB | Output is correct |
17 | Correct | 50 ms | 3560 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 349 ms | 31840 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 467 ms | 31844 KB | Output is correct |
3 | Correct | 492 ms | 31756 KB | Output is correct |
4 | Correct | 448 ms | 31812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 467 ms | 31844 KB | Output is correct |
3 | Correct | 492 ms | 31756 KB | Output is correct |
4 | Correct | 448 ms | 31812 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 472 ms | 31804 KB | Output is correct |
7 | Correct | 451 ms | 31932 KB | Output is correct |
8 | Correct | 450 ms | 31804 KB | Output is correct |
9 | Correct | 498 ms | 31804 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 467 ms | 31844 KB | Output is correct |
3 | Correct | 492 ms | 31756 KB | Output is correct |
4 | Correct | 448 ms | 31812 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 44 ms | 3596 KB | Output is correct |
7 | Correct | 49 ms | 3560 KB | Output is correct |
8 | Correct | 46 ms | 3560 KB | Output is correct |
9 | Correct | 46 ms | 3560 KB | Output is correct |
10 | Correct | 46 ms | 3560 KB | Output is correct |
11 | Correct | 50 ms | 3560 KB | Output is correct |
12 | Correct | 44 ms | 3560 KB | Output is correct |
13 | Correct | 47 ms | 3560 KB | Output is correct |
14 | Correct | 44 ms | 3560 KB | Output is correct |
15 | Correct | 54 ms | 3560 KB | Output is correct |
16 | Correct | 47 ms | 3560 KB | Output is correct |
17 | Correct | 46 ms | 3560 KB | Output is correct |
18 | Correct | 465 ms | 31932 KB | Output is correct |
19 | Correct | 448 ms | 31804 KB | Output is correct |
20 | Correct | 514 ms | 31872 KB | Output is correct |
21 | Correct | 48 ms | 3560 KB | Output is correct |
22 | Correct | 42 ms | 3560 KB | Output is correct |
23 | Correct | 144 ms | 12764 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 49 ms | 3704 KB | Output is correct |
3 | Correct | 48 ms | 3560 KB | Output is correct |
4 | Correct | 531 ms | 31804 KB | Output is correct |
5 | Correct | 47 ms | 3560 KB | Output is correct |
6 | Correct | 47 ms | 3560 KB | Output is correct |
7 | Correct | 51 ms | 3560 KB | Output is correct |
8 | Correct | 50 ms | 3692 KB | Output is correct |
9 | Correct | 49 ms | 3560 KB | Output is correct |
10 | Correct | 48 ms | 3684 KB | Output is correct |
11 | Correct | 50 ms | 3704 KB | Output is correct |
12 | Correct | 42 ms | 3560 KB | Output is correct |
13 | Correct | 48 ms | 3560 KB | Output is correct |
14 | Correct | 504 ms | 31804 KB | Output is correct |
15 | Correct | 47 ms | 3560 KB | Output is correct |
16 | Correct | 458 ms | 31804 KB | Output is correct |
17 | Correct | 447 ms | 31804 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 5 ms | 876 KB | Output is correct |
3 | Correct | 5 ms | 876 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 5 ms | 876 KB | Output is correct |
17 | Correct | 50 ms | 3560 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 492 KB | Output is correct |
20 | Incorrect | 1 ms | 364 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |