답안 #649775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
649775 2022-10-11T10:48:25 Z ToroTN 이상한 기계 (APIO19_strange_device) C++14
65 / 100
525 ms 17592 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
ll n,a,b,x,y,md,cnt=0,mx=-1,l,r,di;
set<pair<ll,ll> > s;
vector<pair<ll,ll> > v;
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    di=a/__gcd(b+1,a);
    if(di>(1e18+1)/b)
    {
        md=1e18+1;
    }else
    {
        md=di*b;
    }
    //printf("%lld\n",md);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        x%=md;
        y%=md;
        if(x<=y)
        {
            v.pb({x,y});
        }else
        {
            v.pb({x,md-1});
            v.pb({0,y});
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        l=v[i].X;
        r=v[i].Y;
        if(l>mx)
        {
            cnt+=(r-l+1);
            mx=r;
        }else
        {
            if(r>mx)
            {
                cnt+=r-mx;
                mx=r;
            }
        }
    }
    printf("%lld\n",cnt);
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
strange_device.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%lld%lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 6 ms 924 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 940 KB Output is correct
17 Correct 48 ms 2600 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 340 KB Output is correct
5 Correct 300 ms 17068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 431 ms 16804 KB Output is correct
3 Correct 417 ms 17440 KB Output is correct
4 Correct 417 ms 17472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 431 ms 16804 KB Output is correct
3 Correct 417 ms 17440 KB Output is correct
4 Correct 417 ms 17472 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 416 ms 17440 KB Output is correct
7 Correct 441 ms 17320 KB Output is correct
8 Correct 430 ms 17376 KB Output is correct
9 Correct 454 ms 17376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 431 ms 16804 KB Output is correct
3 Correct 417 ms 17440 KB Output is correct
4 Correct 417 ms 17472 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 49 ms 2652 KB Output is correct
7 Correct 45 ms 2652 KB Output is correct
8 Correct 43 ms 2720 KB Output is correct
9 Correct 46 ms 2736 KB Output is correct
10 Correct 45 ms 2576 KB Output is correct
11 Correct 43 ms 2704 KB Output is correct
12 Correct 42 ms 2700 KB Output is correct
13 Correct 47 ms 2568 KB Output is correct
14 Correct 40 ms 2736 KB Output is correct
15 Correct 54 ms 2684 KB Output is correct
16 Correct 44 ms 2660 KB Output is correct
17 Correct 44 ms 2704 KB Output is correct
18 Correct 415 ms 17236 KB Output is correct
19 Correct 398 ms 17360 KB Output is correct
20 Correct 465 ms 17364 KB Output is correct
21 Correct 44 ms 2612 KB Output is correct
22 Correct 39 ms 2476 KB Output is correct
23 Correct 140 ms 9092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 44 ms 2600 KB Output is correct
3 Correct 42 ms 2744 KB Output is correct
4 Correct 525 ms 17592 KB Output is correct
5 Correct 43 ms 2528 KB Output is correct
6 Correct 43 ms 2648 KB Output is correct
7 Correct 47 ms 2696 KB Output is correct
8 Correct 54 ms 2552 KB Output is correct
9 Correct 45 ms 2584 KB Output is correct
10 Correct 44 ms 2696 KB Output is correct
11 Correct 46 ms 2668 KB Output is correct
12 Correct 42 ms 2700 KB Output is correct
13 Correct 49 ms 2636 KB Output is correct
14 Correct 461 ms 17232 KB Output is correct
15 Correct 49 ms 2640 KB Output is correct
16 Correct 391 ms 17428 KB Output is correct
17 Correct 468 ms 17196 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 852 KB Output is correct
3 Correct 6 ms 924 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 940 KB Output is correct
17 Correct 48 ms 2600 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Incorrect 1 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -