답안 #721456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721456 2023-04-11T01:52:37 Z Darren0724 이상한 기계 (APIO19_strange_device) C++17
10 / 100
444 ms 16864 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
const int INF=9e18;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;cin>>t;
    int a,b;cin>>a>>b;
    __int128 m=(__int128)a*b;
    vector<pair<int,int>> v;
    for(int i=0;i<t;i++){
        int l,r;cin>>l>>r;
        if(r-l+1>=m){
            cout<<(long long)m<<endl;
            return 0;
        }
        if(r%m<l%m){
            v.push_back({l%m,m-1});
            v.push_back({0,r%m});
        }
        else{
            v.push_back({l%m,r%m});
        }
    }
    sort(all(v));
    __int128 ans=0;
    int l=0;
    for(pair<int,int> p:v){
        p.first=max(p.first,l);
        if(p.second<p.first){
            continue;
        }
        ans+=(p.second-p.first+1);
        l=p.second+1;
    }
    cout<<(long long)ans<<endl;


    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 628 KB Output is correct
3 Correct 5 ms 600 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 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 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 290 ms 16836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 407 ms 16852 KB Output is correct
3 Incorrect 399 ms 16864 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 407 ms 16852 KB Output is correct
3 Incorrect 399 ms 16864 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 407 ms 16852 KB Output is correct
3 Incorrect 399 ms 16864 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 43 ms 2512 KB Output is correct
3 Correct 49 ms 2412 KB Output is correct
4 Correct 444 ms 16812 KB Output is correct
5 Correct 42 ms 2512 KB Output is correct
6 Correct 42 ms 2392 KB Output is correct
7 Correct 42 ms 2440 KB Output is correct
8 Correct 41 ms 2440 KB Output is correct
9 Correct 41 ms 2512 KB Output is correct
10 Correct 41 ms 2512 KB Output is correct
11 Correct 42 ms 2428 KB Output is correct
12 Correct 36 ms 2416 KB Output is correct
13 Correct 43 ms 2404 KB Output is correct
14 Correct 424 ms 16812 KB Output is correct
15 Incorrect 42 ms 2456 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 628 KB Output is correct
3 Correct 5 ms 600 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -