답안 #171489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171489 2019-12-28T18:46:31 Z losmi247 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 405904 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll,ll> p;
const int N = 1e6+56;
const ll inf = 4e18;

ll n,a,b,l[N],r[N];

void prvi(){
    map <p,bool> mapa;
    for(int i = 1; i <= n; i++){
        for(int t = l[i]; t <= r[i]; t++){
            ll x = (t+t/b)%a,y = t%b;
            mapa[p(x,y)] = 1;
        }
    }
    cout << mapa.size() << endl;
}

void drugi(){
    ll period = a*b;
    ll x = l[1],y = r[1];
    if(x-y+1 >= period){
        cout << period << endl;
    }
    else{
        cout << (x-y+1)%period << endl;
    }
}

void treci(){
    
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    ll s = 0;
    for(int i = 1; i <= n; i++){
        cin >> l[i] >> r[i];
        s += r[i]-l[i]+1;
    }
    /*for(int t = 0; t <= 300; t++){
        ll x = (t+t/b)%a,y = t%b;
        cout << "za t = " << t << " " << x << " " << y << endl;
    }*/
    if(s <= 1000000){
        prvi();
        return 0;
    }
    if(n == 1){
        drugi();
        return 0;
    }
    if(a <= b/inf && a*b <= 1000000){
        treci();
        return 0;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 5034 ms 405904 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 5103 ms 60680 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 483 ms 32888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 483 ms 32888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 483 ms 32888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 50 ms 5668 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 5034 ms 405904 KB Time limit exceeded
3 Halted 0 ms 0 KB -