답안 #938937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938937 2024-03-05T22:12:59 Z Andreibatman 이상한 기계 (APIO19_strange_device) C++14
0 / 100
396 ms 17024 KB
#include <bits/stdc++.h>
using namespace std;
unsigned long long n,a,b,ans,i,t,k,pozst,lg,schema,ok,st,dr,x;
struct ceva
{
    unsigned long long l,r;
}v[5000010];
bool cmp(ceva a,ceva b)
{
    return a.r<b.r || (a.r==b.r && a.l<b.l);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>a>>b;
    b++;
    x=__gcd(a,b);
    a=a/x;
    if(ULLONG_MAX/b<a)
        k=1e18;
    else
        k=a*b;
    k=k-a;
    for(i=1;i<=n;i++)
    {
        cin>>v[i].l>>v[i].r;
        if(v[i].r-v[i].l+1>=k)
        {
            cout<<k;
            return 0;
        }
        v[i].l%=k;
        v[i].r%=k;
        if(v[i].l<=v[i].r)
            ;
        else
        {
            v[n+(++schema)]={v[i].l,k-1};
            v[i]={0,v[i].r};
        }
    }
    /*if(ok==1)
    {
        cout<<k;
        return 0;
    }*/
    n=n+schema;
    sort(v+1,v+n+1,cmp);
    //for(i=1;i<=n;i++)
    //    cout<<v[i].l<<" "<<v[i].r<<'\n';
    st=0;
    dr=0;
    for(i=1;i<=n;i++)
    {
        st=max(st,v[i].l);
        st=max(st,v[i-1].r+1);
        if(dr==v[i].r)
            continue;
        dr=v[i].r;
        st=max(st,v[i].l);
        st=max(st,v[i-1].r+1);
        ans=ans+dr-st+1;
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 339 ms 17024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 339 ms 17024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 339 ms 17024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 35 ms 2652 KB Output is correct
3 Correct 38 ms 3052 KB Output is correct
4 Correct 396 ms 16976 KB Output is correct
5 Correct 38 ms 2668 KB Output is correct
6 Correct 36 ms 2652 KB Output is correct
7 Correct 39 ms 2648 KB Output is correct
8 Correct 38 ms 2668 KB Output is correct
9 Correct 35 ms 2648 KB Output is correct
10 Correct 36 ms 2652 KB Output is correct
11 Correct 44 ms 2672 KB Output is correct
12 Incorrect 30 ms 2652 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 3 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -