20662022-12-16 08:57:52kohumarkRendezéscpp11Time limit exceeded 16/40400ms5132 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<n; 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/03ms1896 KiB
2Time limit exceeded0/0400ms1508 KiB
3Accepted2/22ms2416 KiB
4Accepted2/22ms2620 KiB
5Accepted2/22ms2732 KiB
6Accepted2/22ms2840 KiB
7Accepted2/214ms2828 KiB
8Accepted2/214ms2832 KiB
9Accepted2/217ms3100 KiB
10Accepted2/217ms3144 KiB
11Time limit exceeded0/2372ms4040 KiB
12Time limit exceeded0/2368ms4256 KiB
13Time limit exceeded0/2370ms4456 KiB
14Time limit exceeded0/1358ms4500 KiB
15Time limit exceeded0/2365ms4712 KiB
16Time limit exceeded0/2374ms4704 KiB
17Time limit exceeded0/2358ms4720 KiB
18Time limit exceeded0/2365ms4792 KiB
19Time limit exceeded0/2358ms4740 KiB
20Time limit exceeded0/1356ms4996 KiB
21Time limit exceeded0/2358ms4928 KiB
22Time limit exceeded0/2400ms4852 KiB
23Time limit exceeded0/2361ms5132 KiB