답안 #646041

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646041 2022-09-28T14:15:31 Z Tenis0206 이상한 기계 (APIO19_strange_device) C++11
5 / 100
613 ms 33340 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n,a,b;

vector<pair<int,int>> eves;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
        int l,r;
        cin>>l>>r;
        if(r - l + 1 >= 1LL * a * b)
        {
            cout<<1LL * a * b<<'\n';
            return 0;
        }
        l %= 1LL * a * b;
        r %= 1LL * a * b;
        if(l <= r)
        {
            eves.push_back({l,1});
            eves.push_back({r+1,-1});
        }
        else
        {
            eves.push_back({0,1});
            eves.push_back({r+1,-1});
            eves.push_back({l,1});
            eves.push_back({1LL * a * b,-1});
        }
    }
    sort(eves.begin(),eves.end());
    int nr = 0;
    int rez = 0;
    int last = 0;
    for(auto it : eves)
    {
        if(nr==0 && it.second==1)
        {
            last = it.first;
        }
        nr += it.second;
        if(nr==0 && it.second==-1)
        {
            rez += it.first - last;
        }
    }
    cout<<rez<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 856 KB Output is correct
3 Correct 5 ms 856 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 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 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 1 ms 340 KB Output is correct
5 Correct 416 ms 33324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 465 ms 33316 KB Output is correct
3 Incorrect 430 ms 33340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 465 ms 33316 KB Output is correct
3 Incorrect 430 ms 33340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 465 ms 33316 KB Output is correct
3 Incorrect 430 ms 33340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 50 ms 4520 KB Output is correct
3 Correct 52 ms 4464 KB Output is correct
4 Correct 613 ms 33160 KB Output is correct
5 Correct 55 ms 4560 KB Output is correct
6 Correct 52 ms 4556 KB Output is correct
7 Correct 51 ms 4552 KB Output is correct
8 Correct 53 ms 4472 KB Output is correct
9 Correct 50 ms 4512 KB Output is correct
10 Correct 53 ms 4536 KB Output is correct
11 Correct 52 ms 4568 KB Output is correct
12 Correct 59 ms 4456 KB Output is correct
13 Correct 51 ms 4556 KB Output is correct
14 Correct 541 ms 33280 KB Output is correct
15 Incorrect 53 ms 4476 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 856 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -