20632022-12-16 08:53:28kohumarkRendezéscpp11Time limit exceeded 25/40379ms6384 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned int n, m;
    cin >> n >> m;
    int r[m][2];
    int s[n]; bool ok=true;
    for(int i=0; i<n; i++) cin >> s[i];
    for(int i=0; i<m; i++) cin >> r[i][0] >> r[i][1]; int e[n];
    while(ok){
        ok = false;
        for(int i=0; i<n; i++) e[i]=s[i];
        for(int i=0; i<m; i++) sort(s+(r[i][0]-1), s+(r[i][1]));
        for(int i=0; i<n; i++) if(e[i]!=s[i]) ok=true;
    }
    int j=0;
    for(int i=0; i<n; i++) if(s[i]==i+1) j++;
    cout << j;
}
SubtaskSumTestVerdictTimeMemory
base25/40
1Accepted0/03ms1896 KiB
2Accepted0/025ms2532 KiB
3Accepted2/22ms2284 KiB
4Accepted2/22ms2500 KiB
5Accepted2/22ms2568 KiB
6Accepted2/22ms2692 KiB
7Accepted2/22ms2920 KiB
8Accepted2/22ms2888 KiB
9Accepted2/23ms3100 KiB
10Accepted2/22ms3092 KiB
11Accepted2/239ms6176 KiB
12Accepted2/234ms6300 KiB
13Accepted2/235ms6376 KiB
14Accepted1/135ms6376 KiB
15Accepted2/235ms6384 KiB
16Time limit exceeded0/2379ms4000 KiB
17Time limit exceeded0/2368ms3992 KiB
18Time limit exceeded0/2372ms4084 KiB
19Time limit exceeded0/2352ms4200 KiB
20Time limit exceeded0/1333ms4300 KiB
21Time limit exceeded0/2356ms4488 KiB
22Time limit exceeded0/2372ms4548 KiB
23Time limit exceeded0/2377ms4496 KiB