답안 #484577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484577 2021-11-04T13:13:47 Z CyberSleeper 이상한 기계 (APIO19_strange_device) C++14
0 / 100
108 ms 33208 KB
#include <bits/stdc++.h>
#define fastio      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x)    cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define fi          first
#define se          second
#define mp          make_pair
#define pb          push_back
#define ll          long long
#define pll         pair<ll, ll>
#define ull         unsigned long long
#define ld          long double
#define pii         pair<ll, ll>
#define nl          '\n'
#define tb          '\t'
#define sp          ' '
using namespace std;

const ll MX=1000001, MOD=998244353, BLOCK=330, INF=1e9+7, INFF=1e18;
const ld ERR=1e-7, pi=3.14159265358979323846;

ll N, A, B, cyc, last=0;
vector<pll> L;

int main(){
    fastio;
    cin >> N >> A >> B;
    cyc=A/__gcd(A, B+1ll)*B;
    if(cyc<=0)
        cyc=INFF;
    for(int i=0, x, y; i<N; i++){
        cin >> x >> y;
        if(y-x+1>=cyc){
            L.pb({0, cyc-1});
        }else{
            x%=cyc;
            y%=cyc;
            if(x<=y)
                L.pb({x, y});
            else{
                L.pb({0, y});
                L.pb({x, cyc-1});
            }
        }
    }
    N=L.size();
    sort(L.begin(), L.end());
    ll ans=0;
    for(auto i:L){
        ll x=i.fi, y=i.se;
        if(y<last)
            continue;
        x=max(last, x);
        ans+=y-x+1;
        last=max(last, y+1);
    }
    cout << ans << nl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 848 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 108 ms 33208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 108 ms 33208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 108 ms 33208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 10 ms 4496 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 2 ms 848 KB Output isn't correct
3 Halted 0 ms 0 KB -