36412023-03-01 14:38:49Erik_GepardÁruszállítás üres szakaszaicpp17Wrong answer 2/5035ms5076 KiB
#include <bits/stdc++.h>
using namespace std;


void solve(){
    int n, m;
    cin>>n>>m;
    vector<pair<int,int>> a(m);
    for(int i=0; i<m; i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(), a.end());
    int covered=a[0].second, ans=a[0].first-1;
    for(int i=1; i<m; i++){
        if(a[i].first>covered){
            ans+=a[i].first-covered;
        }
        covered=max(a[i].second, covered);
    }
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/03ms1828 KiB
2Wrong answer0/035ms3484 KiB
3Wrong answer0/23ms2232 KiB
4Accepted2/23ms2328 KiB
5Wrong answer0/23ms2544 KiB
6Wrong answer0/23ms2756 KiB
7Wrong answer0/23ms2836 KiB
8Wrong answer0/23ms2968 KiB
9Wrong answer0/23ms3052 KiB
10Wrong answer0/23ms3048 KiB
11Wrong answer0/23ms3056 KiB
12Wrong answer0/23ms3184 KiB
13Wrong answer0/34ms3312 KiB
14Wrong answer0/34ms3324 KiB
15Wrong answer0/34ms3316 KiB
16Wrong answer0/327ms4480 KiB
17Wrong answer0/328ms4732 KiB
18Wrong answer0/332ms4820 KiB
19Wrong answer0/34ms3552 KiB
20Wrong answer0/34ms3556 KiB
21Wrong answer0/332ms4688 KiB
22Wrong answer0/334ms5076 KiB