답안 #810248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810248 2023-08-06T07:32:34 Z peteza 이상한 기계 (APIO19_strange_device) C++14
0 / 100
398 ms 36940 KB
#include <bits/stdc++.h>
using namespace std;

int n;
long long a, b, mod;
long long l, r, last=0, sum = 0;
vector<pair<long long, bool>> vec;
int ctr = 0;

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    cin >> n >> a >> b; a /= __gcd(a, b);
    if(a >= 4e18/b) mod = 4e18;
    else mod = a*b;
    while(n--) {
        cin >> l >> r;
        if(r-l+1 >= mod) {
            cout << mod;
            return 0;
        }
        l %= mod; r %= mod;
        if(l <= r) vec.emplace_back(l, 0), vec.emplace_back(r+1, 1);
        else vec.emplace_back(l, 0), vec.emplace_back(mod, 1), vec.emplace_back(0, 0), vec.emplace_back(r+1, 1);
    }
    sort(vec.begin(), vec.end());
    for(auto e:vec) {
        sum += min(ctr, 1) * (e.first-last);
        if(e.second) ctr--;
        else ctr++;
        last = e.first;
    }
    cout << sum;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 6 ms 1312 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 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 398 ms 35252 KB Output is correct
3 Incorrect 377 ms 36940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 398 ms 35252 KB Output is correct
3 Incorrect 377 ms 36940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 398 ms 35252 KB Output is correct
3 Incorrect 377 ms 36940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 47 ms 7292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 6 ms 1312 KB Output isn't correct
3 Halted 0 ms 0 KB -