답안 #648934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
648934 2022-10-08T18:11:11 Z FEDIKUS 이상한 기계 (APIO19_strange_device) C++17
35 / 100
2086 ms 63096 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll period=-1;
    if(a/__gcd(a,b+1)>(1e18+10)/b+1) period=1e18+10;
    period=a/__gcd(a,b+1)*b;
    map<ll,ll> ev;
    for(int i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        if(r-l+1>=period){
            ev[0]++;
            ev[period]--;
            continue;
        }
        l%=period;
        r%=period;
        if(l<=r){
            ev[l]++;
            ev[r+1]--;
        }else{
            ev[0]++;
            ev[r+1]--;
            ev[l]++;
            ev[period]--;
        }
    }
    ll res=0;
    ll tren=0;
    ll prosli=-1;
    for(auto i:ev){
        tren+=i.second;
        if(tren>0){
            if(prosli==-1) prosli=i.first;
        }else{
            if(res!=-1) res+=i.first-prosli;
            prosli=-1;
        }
    }
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 15 ms 852 KB Output is correct
3 Correct 14 ms 916 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 15 ms 892 KB Output is correct
17 Correct 153 ms 6568 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 368 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 900 ms 280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1566 ms 63012 KB Output is correct
3 Correct 1589 ms 62928 KB Output is correct
4 Correct 1626 ms 62912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1566 ms 63012 KB Output is correct
3 Correct 1589 ms 62928 KB Output is correct
4 Correct 1626 ms 62912 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1597 ms 63024 KB Output is correct
7 Correct 1576 ms 63016 KB Output is correct
8 Correct 1579 ms 62948 KB Output is correct
9 Correct 1658 ms 62816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1566 ms 63012 KB Output is correct
3 Correct 1589 ms 62928 KB Output is correct
4 Correct 1626 ms 62912 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 152 ms 6456 KB Output is correct
7 Correct 144 ms 6524 KB Output is correct
8 Correct 154 ms 6560 KB Output is correct
9 Correct 156 ms 6628 KB Output is correct
10 Correct 152 ms 6616 KB Output is correct
11 Correct 215 ms 6512 KB Output is correct
12 Correct 147 ms 6512 KB Output is correct
13 Correct 156 ms 6524 KB Output is correct
14 Correct 141 ms 6460 KB Output is correct
15 Correct 157 ms 6492 KB Output is correct
16 Correct 155 ms 6444 KB Output is correct
17 Correct 154 ms 6536 KB Output is correct
18 Correct 1547 ms 63048 KB Output is correct
19 Correct 1610 ms 63008 KB Output is correct
20 Correct 2086 ms 63096 KB Output is correct
21 Correct 157 ms 6480 KB Output is correct
22 Correct 147 ms 6436 KB Output is correct
23 Correct 405 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 157 ms 6668 KB Output is correct
3 Correct 158 ms 6476 KB Output is correct
4 Correct 1577 ms 63028 KB Output is correct
5 Correct 156 ms 6476 KB Output is correct
6 Correct 155 ms 6520 KB Output is correct
7 Correct 159 ms 6512 KB Output is correct
8 Correct 158 ms 6448 KB Output is correct
9 Correct 158 ms 6476 KB Output is correct
10 Correct 151 ms 6552 KB Output is correct
11 Correct 152 ms 6676 KB Output is correct
12 Correct 150 ms 6552 KB Output is correct
13 Correct 157 ms 6480 KB Output is correct
14 Correct 1657 ms 62944 KB Output is correct
15 Correct 142 ms 6440 KB Output is correct
16 Correct 1532 ms 62884 KB Output is correct
17 Correct 1605 ms 63016 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 15 ms 852 KB Output is correct
3 Correct 14 ms 916 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 15 ms 892 KB Output is correct
17 Correct 153 ms 6568 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -