243272026-02-09 14:38:41PKALeghosszabb béke (75 pont)cpp17Wrong answer 0/7575ms1316 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 < napok; i++ ){
        haborus[i] = haborus[i-1]+haborus[i];
    }
    for(int i = 0; i < napok; i++ ){
        cout << haborus[i] <<" ";
    }
    cout <<endl;
    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-1<<" "<<kezdopontmax+1;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/01ms316 KiB
2Wrong answer0/075ms1316 KiB
3Wrong answer0/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/42ms316 KiB
9Wrong answer0/42ms316 KiB
10Wrong answer0/43ms316 KiB
11Wrong answer0/44ms436 KiB
12Wrong answer0/48ms472 KiB
13Wrong answer0/46ms316 KiB
14Wrong answer0/46ms508 KiB
15Wrong answer0/48ms316 KiB
16Wrong answer0/48ms608 KiB
17Wrong answer0/410ms724 KiB
18Wrong answer0/412ms660 KiB
19Wrong answer0/470ms1236 KiB
20Wrong answer0/471ms1316 KiB
21Wrong answer0/468ms1060 KiB
22Wrong answer0/470ms1312 KiB