답안 #934421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934421 2024-02-27T10:07:31 Z vjudge1 이상한 기계 (APIO19_strange_device) C++17
0 / 100
420 ms 75572 KB
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 1000000000
#define INF2 2000000000000000000
//#define ll long long
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
///ofstream fout("herding.out");
///ifstream fin("herding.in");

int main()
{
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    long long n, a, b; cin >> n >> a >> b;
    pair<long long, long long> p[n];
    vector<pair<long long,int>> v;
    for(int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
        p[i].first *= 2ll;
        p[i].second *= 2ll;
        pair<long long, long long> pp;
        pp = p[i];
        p[i].first %= a;
        p[i].second %= a;
        if(p[i].second < p[i].first) {
            if(pp.second-pp.first+1 >= a) {
                cout << a << endl; return 0;
            }
            v.push_back({p[i].first,0});
            v.push_back({a-1,1});
            v.push_back({0,0});
            v.push_back({p[i].second,1});
        }
        else {
            v.push_back({p[i].first,0});
            v.push_back({p[i].second,1});
        }
    }
    sort(v.begin(),v.end()); int cnt = 0;
    long long l = -1, r = 0; 
    long long ans = 0;
    for(int i = 0; i < v.size(); i++) {
        if(v[i].second == 0) {
            cnt++;
            if(l == -1) l = v[i].first;
        }
        else {
            cnt--;
            r = max(v[i].first,r);
        }
        if(cnt == 0) {
            ans += r-l+1;
            l = -1, r = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 4 ms 1504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 420 ms 75572 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 420 ms 75572 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 420 ms 75572 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 1884 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 4 ms 1504 KB Output isn't correct
3 Halted 0 ms 0 KB -