244862026-02-12 09:30:50tamasnagyLeghosszabb béke (75 pont)cpp17Wrong answer 30/7575ms1144 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<pair<int,int>>hab;
bool cmp(pair<int,int> a, pair<int,int> b){
    return a.first<b.first;
}

int main()
{
    int days,n;
    cin>>days>>n;
    hab.resize(n);
    for(int i=0; i<n; i++){
        cin>>hab[i].first>>hab[i].second;
    }
    sort(hab.begin(),hab.end(),cmp);
    int maxhossz=hab[0].first-1;
    int maxhindex=1;
    int maxveg=0;
    for(int i=0; i<n; i++){
        if(maxveg<hab[i].first){
            if(maxhossz<hab[i].first-maxveg){
                maxhossz=hab[i].first-maxveg;
                maxhindex=maxveg+1;
            }
        }
        if(maxveg<hab[i].second){
            maxveg=hab[i].second;
        }
    }
    cout<<maxhossz-1<<' '<<maxhindex;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/75
1Accepted0/01ms316 KiB
2Wrong answer0/075ms1076 KiB
3Wrong answer0/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms348 KiB
9Wrong answer0/41ms556 KiB
10Wrong answer0/41ms316 KiB
11Wrong answer0/44ms316 KiB
12Wrong answer0/46ms316 KiB
13Wrong answer0/44ms316 KiB
14Wrong answer0/44ms316 KiB
15Wrong answer0/47ms500 KiB
16Accepted4/47ms316 KiB
17Accepted4/47ms316 KiB
18Accepted4/47ms472 KiB
19Wrong answer0/468ms1120 KiB
20Accepted4/468ms1076 KiB
21Accepted4/464ms948 KiB
22Accepted4/468ms1144 KiB