답안 #938939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938939 2024-03-05T22:20:15 Z Andreibatman 이상한 기계 (APIO19_strange_device) C++14
100 / 100
430 ms 54664 KB
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,ans,i,t,k,pozst,lg,schema,ok,st,dr,x;
struct ceva
{
    long long l,r;
}v[5000010];
bool cmp(ceva a,ceva b)
{
    return a.l<b.l || (a.l==b.l && a.r<b.r);
}
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};
        }
    }
    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=-1;
    dr=0;
    for(i=1;i<=n;i++)
    {
        if(v[i].r<=st)
            continue;
        ans=ans+v[i].r-max(v[i].l-1,st);
        st=v[i].r;
    }
    cout<<ans;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:21:20: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   21 |     if(ULLONG_MAX/b<a)
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 860 KB Output is correct
17 Correct 40 ms 6400 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 476 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 235 ms 42488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 337 ms 17024 KB Output is correct
3 Correct 398 ms 17036 KB Output is correct
4 Correct 322 ms 54096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 337 ms 17024 KB Output is correct
3 Correct 398 ms 17036 KB Output is correct
4 Correct 322 ms 54096 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 348 ms 54232 KB Output is correct
7 Correct 365 ms 54236 KB Output is correct
8 Correct 360 ms 54376 KB Output is correct
9 Correct 418 ms 54000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 337 ms 17024 KB Output is correct
3 Correct 398 ms 17036 KB Output is correct
4 Correct 322 ms 54096 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 34 ms 6388 KB Output is correct
7 Correct 37 ms 6236 KB Output is correct
8 Correct 33 ms 6392 KB Output is correct
9 Correct 33 ms 6228 KB Output is correct
10 Correct 31 ms 6228 KB Output is correct
11 Correct 40 ms 6236 KB Output is correct
12 Correct 32 ms 6236 KB Output is correct
13 Correct 38 ms 6388 KB Output is correct
14 Correct 33 ms 6244 KB Output is correct
15 Correct 41 ms 6228 KB Output is correct
16 Correct 40 ms 6504 KB Output is correct
17 Correct 37 ms 6272 KB Output is correct
18 Correct 362 ms 53884 KB Output is correct
19 Correct 371 ms 54664 KB Output is correct
20 Correct 405 ms 54236 KB Output is correct
21 Correct 38 ms 6228 KB Output is correct
22 Correct 31 ms 6484 KB Output is correct
23 Correct 92 ms 19280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 38 ms 4720 KB Output is correct
3 Correct 40 ms 4720 KB Output is correct
4 Correct 413 ms 35664 KB Output is correct
5 Correct 50 ms 4600 KB Output is correct
6 Correct 38 ms 4692 KB Output is correct
7 Correct 38 ms 4572 KB Output is correct
8 Correct 45 ms 4712 KB Output is correct
9 Correct 37 ms 4688 KB Output is correct
10 Correct 45 ms 4692 KB Output is correct
11 Correct 38 ms 4644 KB Output is correct
12 Correct 33 ms 4840 KB Output is correct
13 Correct 39 ms 5080 KB Output is correct
14 Correct 399 ms 35728 KB Output is correct
15 Correct 38 ms 6228 KB Output is correct
16 Correct 340 ms 54212 KB Output is correct
17 Correct 363 ms 54356 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 860 KB Output is correct
17 Correct 40 ms 6400 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 476 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 235 ms 42488 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 337 ms 17024 KB Output is correct
31 Correct 398 ms 17036 KB Output is correct
32 Correct 322 ms 54096 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 348 ms 54232 KB Output is correct
35 Correct 365 ms 54236 KB Output is correct
36 Correct 360 ms 54376 KB Output is correct
37 Correct 418 ms 54000 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 34 ms 6388 KB Output is correct
40 Correct 37 ms 6236 KB Output is correct
41 Correct 33 ms 6392 KB Output is correct
42 Correct 33 ms 6228 KB Output is correct
43 Correct 31 ms 6228 KB Output is correct
44 Correct 40 ms 6236 KB Output is correct
45 Correct 32 ms 6236 KB Output is correct
46 Correct 38 ms 6388 KB Output is correct
47 Correct 33 ms 6244 KB Output is correct
48 Correct 41 ms 6228 KB Output is correct
49 Correct 40 ms 6504 KB Output is correct
50 Correct 37 ms 6272 KB Output is correct
51 Correct 362 ms 53884 KB Output is correct
52 Correct 371 ms 54664 KB Output is correct
53 Correct 405 ms 54236 KB Output is correct
54 Correct 38 ms 6228 KB Output is correct
55 Correct 31 ms 6484 KB Output is correct
56 Correct 92 ms 19280 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 38 ms 4720 KB Output is correct
59 Correct 40 ms 4720 KB Output is correct
60 Correct 413 ms 35664 KB Output is correct
61 Correct 50 ms 4600 KB Output is correct
62 Correct 38 ms 4692 KB Output is correct
63 Correct 38 ms 4572 KB Output is correct
64 Correct 45 ms 4712 KB Output is correct
65 Correct 37 ms 4688 KB Output is correct
66 Correct 45 ms 4692 KB Output is correct
67 Correct 38 ms 4644 KB Output is correct
68 Correct 33 ms 4840 KB Output is correct
69 Correct 39 ms 5080 KB Output is correct
70 Correct 399 ms 35728 KB Output is correct
71 Correct 38 ms 6228 KB Output is correct
72 Correct 340 ms 54212 KB Output is correct
73 Correct 363 ms 54356 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 0 ms 344 KB Output is correct
76 Correct 0 ms 348 KB Output is correct
77 Correct 0 ms 348 KB Output is correct
78 Correct 0 ms 344 KB Output is correct
79 Correct 3 ms 860 KB Output is correct
80 Correct 425 ms 54460 KB Output is correct
81 Correct 417 ms 54236 KB Output is correct
82 Correct 399 ms 54240 KB Output is correct
83 Correct 397 ms 54196 KB Output is correct
84 Correct 430 ms 54248 KB Output is correct
85 Correct 397 ms 54148 KB Output is correct
86 Correct 93 ms 19288 KB Output is correct
87 Correct 1 ms 600 KB Output is correct