답안 #397857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397857 2021-05-03T09:51:29 Z Anand 이상한 기계 (APIO19_strange_device) C++14
100 / 100
1899 ms 53408 KB
#include<bits/stdc++.h>

using namespace std;


int main()
{
    vector<pair<long long , long long>> v;
    long long n , a , b;
    cin >> n >> a >> b;

    long long s , f , ans = 0;

    a/=__gcd(a , b+1);

    if(a > 1e18/b) a = 1e18 + 1;
    else a = a * b;

    for(long long i = 0; i < n; i++)
    {
        long long l , r;
        cin >> l >> r;
        if(r - l + 1 >= a) v.push_back({0,a-1});
        else if((r % a) < (l % a)) {v.push_back({l % a , a - 1}); v.push_back({0 , r % a});}
        else v.push_back({l % a , r % a});
    }

    sort(v.begin(),v.end());

    s = v[0].first , f = v[0].second;

    for(int i = 1; i < v.size(); i++)
    {
        if(v[i].first>f) ans += f - s + 1 , tie(s , f) = v[i];
        else f = max(f,v[i].second);
    }
    cout << ans+f-s+1 << endl;;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:22: 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]
   32 |     for(int i = 1; i < v.size(); i++)
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 16 ms 972 KB Output is correct
3 Correct 15 ms 1044 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 16 ms 1048 KB Output is correct
17 Correct 157 ms 5696 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1088 ms 41420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1528 ms 53408 KB Output is correct
3 Correct 1476 ms 53252 KB Output is correct
4 Correct 1452 ms 53180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1528 ms 53408 KB Output is correct
3 Correct 1476 ms 53252 KB Output is correct
4 Correct 1452 ms 53180 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1623 ms 53120 KB Output is correct
7 Correct 1533 ms 53184 KB Output is correct
8 Correct 1646 ms 53088 KB Output is correct
9 Correct 1648 ms 52764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1528 ms 53408 KB Output is correct
3 Correct 1476 ms 53252 KB Output is correct
4 Correct 1452 ms 53180 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 155 ms 5664 KB Output is correct
7 Correct 163 ms 5792 KB Output is correct
8 Correct 159 ms 5820 KB Output is correct
9 Correct 162 ms 5688 KB Output is correct
10 Correct 151 ms 5612 KB Output is correct
11 Correct 161 ms 5680 KB Output is correct
12 Correct 151 ms 5628 KB Output is correct
13 Correct 160 ms 5696 KB Output is correct
14 Correct 154 ms 5684 KB Output is correct
15 Correct 157 ms 5700 KB Output is correct
16 Correct 158 ms 5688 KB Output is correct
17 Correct 167 ms 5648 KB Output is correct
18 Correct 1510 ms 53068 KB Output is correct
19 Correct 1551 ms 53144 KB Output is correct
20 Correct 1566 ms 53180 KB Output is correct
21 Correct 150 ms 5620 KB Output is correct
22 Correct 146 ms 5872 KB Output is correct
23 Correct 484 ms 18476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 150 ms 5656 KB Output is correct
3 Correct 152 ms 5684 KB Output is correct
4 Correct 1612 ms 53256 KB Output is correct
5 Correct 150 ms 5680 KB Output is correct
6 Correct 152 ms 5608 KB Output is correct
7 Correct 152 ms 5580 KB Output is correct
8 Correct 151 ms 5824 KB Output is correct
9 Correct 148 ms 5648 KB Output is correct
10 Correct 148 ms 5680 KB Output is correct
11 Correct 152 ms 5612 KB Output is correct
12 Correct 148 ms 5676 KB Output is correct
13 Correct 149 ms 5680 KB Output is correct
14 Correct 1899 ms 52556 KB Output is correct
15 Correct 152 ms 5680 KB Output is correct
16 Correct 1501 ms 53344 KB Output is correct
17 Correct 1479 ms 53232 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 16 ms 972 KB Output is correct
3 Correct 15 ms 1044 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 16 ms 1048 KB Output is correct
17 Correct 157 ms 5696 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 1088 ms 41420 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1528 ms 53408 KB Output is correct
31 Correct 1476 ms 53252 KB Output is correct
32 Correct 1452 ms 53180 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1623 ms 53120 KB Output is correct
35 Correct 1533 ms 53184 KB Output is correct
36 Correct 1646 ms 53088 KB Output is correct
37 Correct 1648 ms 52764 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 155 ms 5664 KB Output is correct
40 Correct 163 ms 5792 KB Output is correct
41 Correct 159 ms 5820 KB Output is correct
42 Correct 162 ms 5688 KB Output is correct
43 Correct 151 ms 5612 KB Output is correct
44 Correct 161 ms 5680 KB Output is correct
45 Correct 151 ms 5628 KB Output is correct
46 Correct 160 ms 5696 KB Output is correct
47 Correct 154 ms 5684 KB Output is correct
48 Correct 157 ms 5700 KB Output is correct
49 Correct 158 ms 5688 KB Output is correct
50 Correct 167 ms 5648 KB Output is correct
51 Correct 1510 ms 53068 KB Output is correct
52 Correct 1551 ms 53144 KB Output is correct
53 Correct 1566 ms 53180 KB Output is correct
54 Correct 150 ms 5620 KB Output is correct
55 Correct 146 ms 5872 KB Output is correct
56 Correct 484 ms 18476 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 150 ms 5656 KB Output is correct
59 Correct 152 ms 5684 KB Output is correct
60 Correct 1612 ms 53256 KB Output is correct
61 Correct 150 ms 5680 KB Output is correct
62 Correct 152 ms 5608 KB Output is correct
63 Correct 152 ms 5580 KB Output is correct
64 Correct 151 ms 5824 KB Output is correct
65 Correct 148 ms 5648 KB Output is correct
66 Correct 148 ms 5680 KB Output is correct
67 Correct 152 ms 5612 KB Output is correct
68 Correct 148 ms 5676 KB Output is correct
69 Correct 149 ms 5680 KB Output is correct
70 Correct 1899 ms 52556 KB Output is correct
71 Correct 152 ms 5680 KB Output is correct
72 Correct 1501 ms 53344 KB Output is correct
73 Correct 1479 ms 53232 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 1 ms 204 KB Output is correct
76 Correct 1 ms 304 KB Output is correct
77 Correct 1 ms 204 KB Output is correct
78 Correct 1 ms 204 KB Output is correct
79 Correct 15 ms 1060 KB Output is correct
80 Correct 1547 ms 53360 KB Output is correct
81 Correct 1557 ms 53300 KB Output is correct
82 Correct 1506 ms 53264 KB Output is correct
83 Correct 1586 ms 53220 KB Output is correct
84 Correct 1521 ms 53192 KB Output is correct
85 Correct 1588 ms 53088 KB Output is correct
86 Correct 505 ms 18480 KB Output is correct
87 Correct 1 ms 208 KB Output is correct