7872022-01-12 13:46:40Kevinke12Rendezéscpp14Time limit exceeded 25/40398ms25544 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

vector<int> t;
vector<int> elozo;
int N, M, be1, be2;
int r[100005][2];

int main()
{
    cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        cin >> be1; t.push_back(be1);
    }
    for(int i = 0; i < M; i++)
    {
        cin >> r[i][0] >> r[i][1];
        r[i][0]--;
        r[i][1]--;
    }

    do
    {
        elozo=t;
        for(int i = 0; i < M; i++)
        {
            sort(t.begin()+r[i][0], t.begin()+r[i][1]+1);
            //for(int a:t) cout << a << " "; cout << "\n";
        }
    }while(elozo!=t);


    int ans=0;
    for(int i = 0; i < N; i++)
    {
        if(i+1==t[i])
            ans++;
    }

    cout << ans << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base25/40
1Accepted0/03ms1952 KiB
2Accepted0/039ms2712 KiB
3Accepted2/21ms2276 KiB
4Accepted2/21ms2284 KiB
5Accepted2/21ms2280 KiB
6Accepted2/21ms2288 KiB
7Accepted2/22ms2312 KiB
8Accepted2/22ms2332 KiB
9Accepted2/22ms2344 KiB
10Accepted2/22ms2356 KiB
11Accepted2/2128ms7188 KiB
12Accepted2/298ms8812 KiB
13Accepted2/287ms10548 KiB
14Accepted1/193ms12280 KiB
15Accepted2/298ms14008 KiB
16Time limit exceeded0/2398ms13524 KiB
17Time limit exceeded0/2381ms15140 KiB
18Time limit exceeded0/2397ms16872 KiB
19Time limit exceeded0/2398ms18600 KiB
20Time limit exceeded0/1397ms20268 KiB
21Time limit exceeded0/2389ms22196 KiB
22Time limit exceeded0/2375ms23992 KiB
23Time limit exceeded0/2389ms25544 KiB