답안 #402063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402063 2021-05-11T09:19:57 Z Blobo2_Blobo2 이상한 기계 (APIO19_strange_device) C++14
5 / 100
558 ms 16912 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define base ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;
const int mo=1e9+7;
int nxt(){int x;cin>>x;return x;}

signed main(){
    base
    int n=nxt(),a=nxt(),b=nxt();
    int x=a*b;
    vector<pair<int,int> >v;
    if(a!=x/b)
        x=1000000000000000001;
    bool flag=0;
    for(int i=0;i<n;i++){
        int first=nxt(),sec=nxt();
        if(sec-first+1==x)flag=1;
        else if(sec%x<first%x){
            first%=x;
            sec%=x;
            v.push_back({first,x-1});
            v.push_back({0,sec});
        }
        else v.push_back({first%x,sec%x});
    }
    if(flag){
        cout<<x<<endl;
        return 0;
    }
    sort(all(v));
    int cnt=0,now=-1;
    for(int i=0;i<v.size();i++){
        if(now==-1){
            now=v[i].second+1;
            cnt+=v[i].second-v[i].first+1;
        }
        else if(now>=v[i].second)
            continue;
        else if(now<v[i].first){
            cnt+=v[i].second-v[i].first+1;
            now=v[i].second+1;
        }
        else if(now>=v[i].first){
            cnt+=v[i].second-now+1;
            now=v[i].second+1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:45: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]
   45 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 5 ms 592 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 350 ms 16776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 484 ms 16800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 484 ms 16800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 484 ms 16800 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 50 ms 2484 KB Output is correct
3 Correct 50 ms 2416 KB Output is correct
4 Correct 558 ms 16912 KB Output is correct
5 Correct 60 ms 2364 KB Output is correct
6 Correct 53 ms 2488 KB Output is correct
7 Correct 50 ms 2472 KB Output is correct
8 Correct 52 ms 2428 KB Output is correct
9 Correct 50 ms 2488 KB Output is correct
10 Correct 50 ms 2420 KB Output is correct
11 Correct 61 ms 2432 KB Output is correct
12 Correct 45 ms 2496 KB Output is correct
13 Correct 51 ms 2564 KB Output is correct
14 Correct 536 ms 16852 KB Output is correct
15 Incorrect 62 ms 2496 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 5 ms 592 KB Output isn't correct
3 Halted 0 ms 0 KB -