63472023-11-22 16:19:11Tina0731Áruszállítás üres szakaszaicpp14Time limit exceeded 13/50400ms7020 KiB
#include <iostream>
#include <bits/stdc++.h>

/*
10 4
8 9
5 8
1 3
3 4

*/

using namespace std;

int main()
{
    pair<int, int> x; //x.first, x.second
    vector<pair<int, int>> parok;

    map<int, int> m;
    int h, n;
    int k, b;
    bool ujkell=true;
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
        ujkell=true;
        cin>>x.first>>x.second;
        for(int j=0;j<parok.size();j++)
        {
            if(parok.at(j).first<=x.first && parok.at(j).second>=x.second)
            {
                ujkell=false;
                break;
            }
            else if(parok.at(j).first<=x.first && parok.at(j).second>=x.first)
            {
                ujkell=false;
                parok.at(j).second=x.second;
                break;
            }
            else if(parok.at(j).first<=x.second && parok.at(j).second>=x.second)
            {
                ujkell=false;
                parok.at(j).first=x.first;
                break;
            }
        }
        if(ujkell==true)
            parok.push_back(x);
    }

    sort(parok.begin(), parok.end());
    /*cout<<endl;
    for(pair<int,int> xx:parok)
        cout<<xx.first<<" "<<xx.second<<endl;*/

    if(!parok.empty())
    {
        int szamol=1;
        for(int j=1;j<parok.size();j++)
        {
            if(parok.at(j-1).second<parok.at(j).first)
                szamol++;
        }
        cout<<szamol;
    }
    else
        cout<<0;




    return 0;
}
SubtaskSumTestVerdictTimeMemory
base13/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0400ms1460 KiB
3Wrong answer0/23ms2264 KiB
4Wrong answer0/23ms2480 KiB
5Wrong answer0/23ms2692 KiB
6Wrong answer0/23ms2776 KiB
7Wrong answer0/23ms2904 KiB
8Wrong answer0/23ms3116 KiB
9Accepted2/22ms3196 KiB
10Accepted2/23ms3280 KiB
11Wrong answer0/23ms3492 KiB
12Wrong answer0/23ms3396 KiB
13Wrong answer0/332ms3436 KiB
14Wrong answer0/390ms3756 KiB
15Wrong answer0/341ms3648 KiB
16Accepted3/359ms4248 KiB
17Accepted3/361ms5112 KiB
18Accepted3/368ms6380 KiB
19Wrong answer0/343ms6800 KiB
20Wrong answer0/372ms7020 KiB
21Time limit exceeded0/3358ms6456 KiB
22Time limit exceeded0/3386ms6468 KiB