243252026-02-09 14:30:06PKALeghosszabb béke (75 pont)cpp17Time limit exceeded 6/75300ms712 KiB
#include <iostream>
#include<vector>
using namespace std;

int main()
{
    int napok;
    int haboruk;
    cin >> napok;
    cin >> haboruk;
    vector<bool>haborus(napok, false);
    for(int i = 0; i < haboruk; i++){
        int temp1;
        int temp2;
        cin >> temp1;
        cin >> temp2;
        for(int i = temp1; i <= temp2; i++){
            haborus[i-1] = true;
        }
    }
    int maxi = 0;
    int kezdopontmax = 0;
    int hossz = 0;
    int kezdopont = 0;
    bool kezdopontf = false;
    for(int i = 0; i < napok; i++){
        if(haborus[i] == false){
            if(kezdopontf  == false){
                hossz = 0;
                kezdopont = i;
                hossz++;
                kezdopontf = true;
            }else{
                hossz++;
            }
        }else{
            kezdopontf = false;
            if(hossz >= maxi){
                maxi = hossz;
                kezdopontmax = kezdopont;
            }
        }
    }
    cout << maxi<<" "<<kezdopontmax+1;
}
SubtaskSumTestVerdictTimeMemory
base6/75
1Accepted0/01ms512 KiB
2Time limit exceeded0/0287ms712 KiB
3Wrong answer0/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms316 KiB
9Wrong answer0/41ms500 KiB
10Wrong answer0/42ms316 KiB
11Wrong answer0/418ms348 KiB
12Wrong answer0/443ms316 KiB
13Wrong answer0/428ms396 KiB
14Wrong answer0/432ms412 KiB
15Wrong answer0/443ms476 KiB
16Time limit exceeded0/4256ms400 KiB
17Time limit exceeded0/4298ms316 KiB
18Time limit exceeded0/4300ms416 KiB
19Time limit exceeded0/4289ms564 KiB
20Time limit exceeded0/4284ms316 KiB
21Time limit exceeded0/4279ms508 KiB
22Time limit exceeded0/4300ms316 KiB