243262026-02-09 14:36:12PKALeghosszabb béke (75 pont)cpp17Wrong answer 3/7564ms996 KiB
#include <iostream>
#include<vector>
using namespace std;

int main()
{
    int napok;
    int haboruk;
    cin >> napok;
    cin >> haboruk;
    vector<int>haborus(napok, 0);
    for(int i = 0; i < haboruk; i++){
        int temp1;
        int temp2;
        cin >> temp1;
        cin >> temp2;
        haborus[temp1] = 1;
        haborus[temp2] = -1;
    }
    for(int i = 1; i < haboruk; i++ ){
        haborus[i] = haborus[i-1]+haborus[i];
    }
    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] == 0){
            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;
}
SubtaskSumTestVerdictTimeMemory
base3/75
1Accepted0/01ms316 KiB
2Wrong answer0/064ms816 KiB
3Wrong answer0/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms400 KiB
6Accepted3/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms492 KiB
9Wrong answer0/41ms316 KiB
10Wrong answer0/41ms508 KiB
11Wrong answer0/44ms316 KiB
12Wrong answer0/46ms472 KiB
13Wrong answer0/44ms316 KiB
14Wrong answer0/44ms316 KiB
15Wrong answer0/46ms500 KiB
16Wrong answer0/46ms512 KiB
17Wrong answer0/46ms568 KiB
18Wrong answer0/47ms564 KiB
19Wrong answer0/459ms996 KiB
20Wrong answer0/459ms564 KiB
21Wrong answer0/457ms804 KiB
22Wrong answer0/459ms800 KiB