20642022-12-16 08:55:13kohumarkRendezéscpp11Time limit exceeded 16/40381ms5240 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];
    for(int l=0; l<m-1; l++){
        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
base16/40
1Accepted0/03ms1768 KiB
2Time limit exceeded0/0340ms1384 KiB
3Accepted2/22ms2228 KiB
4Accepted2/22ms2468 KiB
5Accepted2/22ms2668 KiB
6Accepted2/22ms2744 KiB
7Accepted2/216ms2848 KiB
8Accepted2/217ms2932 KiB
9Accepted2/220ms3052 KiB
10Accepted2/221ms3268 KiB
11Time limit exceeded0/2368ms4248 KiB
12Time limit exceeded0/2340ms4196 KiB
13Time limit exceeded0/2368ms4344 KiB
14Time limit exceeded0/1344ms4100 KiB
15Time limit exceeded0/2345ms4244 KiB
16Time limit exceeded0/2381ms4728 KiB
17Time limit exceeded0/2372ms4940 KiB
18Time limit exceeded0/2358ms5144 KiB
19Time limit exceeded0/2354ms5156 KiB
20Time limit exceeded0/1381ms5144 KiB
21Time limit exceeded0/2354ms5052 KiB
22Time limit exceeded0/2377ms5052 KiB
23Time limit exceeded0/2361ms5240 KiB