33912023-02-27 12:16:05EyusieÁruszállítás üres szakaszaicpp17Wrong answer 14/5083ms5984 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

struct interv
{
    int a;
    int b;
};
bool comp(interv a, interv b)
{
    return a.a < b.a;
}
int main()
{
    int mx;
    int darab;
    cin >> mx >> darab;
    vector<interv> vek;
    interv temp;
    for(int i = 0; i < darab; i++)
    {
      cin >> temp.a >> temp.b;
      vek.push_back(temp);
    }
    sort(vek.begin(), vek.end(), comp);
    vector<interv> vek2;
    vek2.push_back(vek[0]);

    for(int i = 1; i < vek.size(); i++)
    {
        if(vek2[vek2.size()-1].b >= vek[i].a)
            vek2[vek2.size()-1].b = max(vek[i].b,vek2[vek2.size()-1].b);
        else vek2.push_back(vek[i]);
    }
    int szam = vek2.size()-1;
    if(vek2[0].a > 1) szam++;
    if(vek2[vek2.size()+1].b < mx) szam++;
    cout << szam;

}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms1684 KiB
2Wrong answer0/083ms3868 KiB
3Accepted2/23ms2060 KiB
4Wrong answer0/23ms2268 KiB
5Accepted2/23ms2520 KiB
6Accepted2/23ms2552 KiB
7Accepted2/23ms2792 KiB
8Accepted2/23ms2884 KiB
9Wrong answer0/23ms2972 KiB
10Wrong answer0/23ms3212 KiB
11Accepted2/23ms3216 KiB
12Accepted2/23ms3360 KiB
13Wrong answer0/37ms3544 KiB
14Wrong answer0/38ms3708 KiB
15Wrong answer0/36ms3536 KiB
16Wrong answer0/367ms5580 KiB
17Wrong answer0/368ms5632 KiB
18Wrong answer0/378ms5720 KiB
19Wrong answer0/38ms3912 KiB
20Wrong answer0/39ms4196 KiB
21Wrong answer0/376ms5884 KiB
22Wrong answer0/379ms5984 KiB