7882022-01-12 13:48:02Kevinke12Rendezéscpp14Time limit exceeded 25/40398ms25652 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()
{
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

    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/02ms2084 KiB
2Accepted0/023ms2716 KiB
3Accepted2/21ms2292 KiB
4Accepted2/21ms2296 KiB
5Accepted2/22ms2300 KiB
6Accepted2/22ms2304 KiB
7Accepted2/22ms2332 KiB
8Accepted2/22ms2348 KiB
9Accepted2/22ms2364 KiB
10Accepted2/22ms2372 KiB
11Accepted2/237ms7256 KiB
12Accepted2/250ms8976 KiB
13Accepted2/246ms10704 KiB
14Accepted1/134ms12444 KiB
15Accepted2/235ms14176 KiB
16Time limit exceeded0/2397ms13680 KiB
17Time limit exceeded0/2398ms15272 KiB
18Time limit exceeded0/2391ms16948 KiB
19Time limit exceeded0/2398ms18736 KiB
20Time limit exceeded0/1395ms20464 KiB
21Time limit exceeded0/2398ms22192 KiB
22Time limit exceeded0/2379ms23876 KiB
23Time limit exceeded0/2391ms25652 KiB