답안 #744157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744157 2023-05-18T08:47:39 Z iamporrrrrrrrr 이상한 기계 (APIO19_strange_device) C++14
65 / 100
500 ms 19252 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
set<int> s;
vector<pair<int,int>> v;
signed main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int mod = (a*b)/__gcd(a,b+1);
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        x%=mod;
        y%=mod;
        if(y>=x){
            v.push_back({x,y});
        }
        else v.push_back({x,mod-1}),v.push_back({0,y});

    }
    sort(v.begin(),v.end());
    int rr=-1,ans=0;
    for(int i=0;i<v.size();i++){
        int l=v[i].first;
        int r=v[i].second;
        if(l>rr){
            ans+=(r-l+1);
            rr=r;
        }
        else if(l<=rr&&r>rr){
            ans+=(r-rr);
            rr=r;
        }
    }
    cout<<ans;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:25:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 1052 KB Output is correct
3 Correct 7 ms 984 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 212 KB Output is correct
7 Correct 1 ms 324 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 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 1080 KB Output is correct
17 Correct 60 ms 4392 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 307 ms 18756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 500 ms 18420 KB Output is correct
3 Correct 469 ms 18028 KB Output is correct
4 Correct 483 ms 18732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 500 ms 18420 KB Output is correct
3 Correct 469 ms 18028 KB Output is correct
4 Correct 483 ms 18732 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 433 ms 18676 KB Output is correct
7 Correct 472 ms 18976 KB Output is correct
8 Correct 428 ms 18312 KB Output is correct
9 Correct 414 ms 19252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 500 ms 18420 KB Output is correct
3 Correct 469 ms 18028 KB Output is correct
4 Correct 483 ms 18732 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 46 ms 4356 KB Output is correct
7 Correct 42 ms 4320 KB Output is correct
8 Correct 40 ms 4324 KB Output is correct
9 Correct 42 ms 4384 KB Output is correct
10 Correct 50 ms 4148 KB Output is correct
11 Correct 48 ms 4176 KB Output is correct
12 Correct 38 ms 4408 KB Output is correct
13 Correct 43 ms 4396 KB Output is correct
14 Correct 40 ms 4140 KB Output is correct
15 Correct 48 ms 4300 KB Output is correct
16 Correct 57 ms 4392 KB Output is correct
17 Correct 41 ms 4412 KB Output is correct
18 Correct 417 ms 18260 KB Output is correct
19 Correct 405 ms 18240 KB Output is correct
20 Correct 450 ms 18616 KB Output is correct
21 Correct 47 ms 4540 KB Output is correct
22 Correct 52 ms 4384 KB Output is correct
23 Correct 116 ms 10564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 45 ms 4296 KB Output is correct
3 Correct 48 ms 4388 KB Output is correct
4 Correct 488 ms 18304 KB Output is correct
5 Correct 42 ms 4376 KB Output is correct
6 Correct 43 ms 4300 KB Output is correct
7 Correct 44 ms 4404 KB Output is correct
8 Correct 47 ms 4292 KB Output is correct
9 Correct 43 ms 4376 KB Output is correct
10 Correct 41 ms 4404 KB Output is correct
11 Correct 45 ms 4492 KB Output is correct
12 Correct 36 ms 4136 KB Output is correct
13 Correct 44 ms 4300 KB Output is correct
14 Correct 438 ms 18196 KB Output is correct
15 Correct 46 ms 4296 KB Output is correct
16 Correct 398 ms 18148 KB Output is correct
17 Correct 407 ms 18184 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 1052 KB Output is correct
3 Correct 7 ms 984 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 212 KB Output is correct
7 Correct 1 ms 324 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 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 1080 KB Output is correct
17 Correct 60 ms 4392 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Incorrect 1 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -