244852026-02-12 09:30:13tamasnagyLeghosszabb béke (75 pont)cpp17Wrong answer 0/75266ms4916 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++){
        cout<<hab[i].first<<' '<<hab[i].second<<'\n';
    }
    for(int i=0; i<n; i++){
        cout<<hab[i].first<<' '<<hab[i].second<<' '<<maxveg<<' '<<maxhossz<<endl;
        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
base0/75
1Wrong answer0/01ms316 KiB
2Time limit exceeded0/0266ms4916 KiB
3Wrong answer0/31ms316 KiB
4Wrong answer0/31ms500 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms352 KiB
9Wrong answer0/41ms560 KiB
10Wrong answer0/42ms316 KiB
11Wrong answer0/416ms516 KiB
12Wrong answer0/420ms460 KiB
13Wrong answer0/414ms564 KiB
14Wrong answer0/417ms632 KiB
15Wrong answer0/423ms572 KiB
16Wrong answer0/421ms568 KiB
17Wrong answer0/423ms564 KiB
18Wrong answer0/425ms820 KiB
19Time limit exceeded0/4256ms3892 KiB
20Time limit exceeded0/4254ms4916 KiB
21Time limit exceeded0/4243ms4032 KiB
22Time limit exceeded0/4238ms3892 KiB