답안 #217045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217045 2020-03-28T18:27:37 Z sevlll 이상한 기계 (APIO19_strange_device) C++17
35 / 100
947 ms 81852 KB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define int2 __int128_t
#define str string
using namespace std;
const int M = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    vector<pair<int, int>> pr(n);
    for (int i = 0; i < n; i++) cin >> pr[i].first >> pr[i].second;
    int2 g = gcd(a, b + 1);
    a /= g;
    int2 num = a * b;
    vector<pair<int2, int2>> ev;
    for (auto p : pr) {
        int2 l = p.first, r = p.second;
        if (r - l >= num - 1) {
            cout << (int) num;
            return 0;
        }
        l %= num;
        r %= num;
        if (r < l) {
            ev.pb({l, 1});
            ev.pb({num, -1});
            ev.pb({0, 1});
            ev.pb({r + 1, -1});
        } else {
            ev.pb({l, 1});
            ev.pb({r + 1, -1});
        }
    }
    sort(ev.begin(), ev.end());
    int2 bal = 0;
    int2 last = 0;
    int ans = 0;
    for (auto p : ev) {
        int2 x = p.first;
        int2 type = p.second;
        if (bal) {
            ans += (x - last);
        }
        last = x;
        bal += type;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 11 ms 1660 KB Output is correct
3 Correct 11 ms 1660 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 15 ms 1788 KB Output is correct
17 Correct 91 ms 10308 KB Output is correct
18 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 510 ms 81816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 754 ms 81824 KB Output is correct
3 Correct 803 ms 81760 KB Output is correct
4 Correct 767 ms 81824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 754 ms 81824 KB Output is correct
3 Correct 803 ms 81760 KB Output is correct
4 Correct 767 ms 81824 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 780 ms 81788 KB Output is correct
7 Correct 743 ms 81824 KB Output is correct
8 Correct 732 ms 81752 KB Output is correct
9 Correct 937 ms 81852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 754 ms 81824 KB Output is correct
3 Correct 803 ms 81760 KB Output is correct
4 Correct 767 ms 81824 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 73 ms 10220 KB Output is correct
7 Correct 76 ms 10344 KB Output is correct
8 Correct 76 ms 10216 KB Output is correct
9 Correct 75 ms 10216 KB Output is correct
10 Correct 68 ms 10300 KB Output is correct
11 Correct 75 ms 10216 KB Output is correct
12 Correct 74 ms 10216 KB Output is correct
13 Correct 78 ms 10216 KB Output is correct
14 Correct 70 ms 10216 KB Output is correct
15 Correct 85 ms 10216 KB Output is correct
16 Correct 83 ms 10216 KB Output is correct
17 Correct 73 ms 10216 KB Output is correct
18 Correct 749 ms 81828 KB Output is correct
19 Correct 726 ms 81824 KB Output is correct
20 Correct 947 ms 81824 KB Output is correct
21 Correct 84 ms 10268 KB Output is correct
22 Correct 69 ms 10344 KB Output is correct
23 Correct 212 ms 38744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 79 ms 10216 KB Output is correct
3 Correct 79 ms 10216 KB Output is correct
4 Correct 943 ms 81824 KB Output is correct
5 Correct 80 ms 10216 KB Output is correct
6 Correct 84 ms 10216 KB Output is correct
7 Correct 79 ms 10344 KB Output is correct
8 Correct 85 ms 10216 KB Output is correct
9 Correct 75 ms 10220 KB Output is correct
10 Correct 86 ms 10216 KB Output is correct
11 Correct 78 ms 10216 KB Output is correct
12 Correct 75 ms 10216 KB Output is correct
13 Correct 84 ms 10216 KB Output is correct
14 Correct 893 ms 81824 KB Output is correct
15 Correct 88 ms 10216 KB Output is correct
16 Correct 697 ms 81824 KB Output is correct
17 Correct 737 ms 81824 KB Output is correct
18 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 11 ms 1660 KB Output is correct
3 Correct 11 ms 1660 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 15 ms 1788 KB Output is correct
17 Correct 91 ms 10308 KB Output is correct
18 Incorrect 5 ms 384 KB Output isn't correct