20622022-12-16 08:41:43kohumarkRendezéscpp11Wrong answer 11/40363ms6508 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;
    unsigned int r[m][2];
    unsigned 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];
    while(ok){
        ok = false;
//        for(int i=0; i<m; i++) sort(s+(r[i][0]-1), s+(r[i][1]-1));
        for(int i=0; i<m; i++){
            ok=false;
            int m1 = r[i][0]; int m2=r[i][1];
            for(int k=m1-1; k<m2-1; k++){
                for(int j=k+1; j<m2; j++) if(s[k]>s[j]){
                    int x = s[j];
                    s[j] = s[k];
                    s[k] = x;
                    ok = true;
                }
            }
        }
    }
    int j=0;
    for(int i=0; i<n; i++) if(s[i]==i+1) j++;
    cout << j;
}
SubtaskSumTestVerdictTimeMemory
base11/40
1Accepted0/03ms1768 KiB
2Wrong answer0/06ms2356 KiB
3Accepted2/22ms2408 KiB
4Accepted2/22ms2404 KiB
5Wrong answer0/22ms2560 KiB
6Wrong answer0/22ms2764 KiB
7Wrong answer0/22ms2872 KiB
8Wrong answer0/22ms3012 KiB
9Wrong answer0/22ms3188 KiB
10Wrong answer0/22ms3264 KiB
11Wrong answer0/227ms5700 KiB
12Accepted2/227ms5908 KiB
13Accepted2/227ms6136 KiB
14Accepted1/127ms6068 KiB
15Accepted2/227ms6116 KiB
16Time limit exceeded0/2324ms4232 KiB
17Wrong answer0/271ms6128 KiB
18Wrong answer0/264ms6048 KiB
19Wrong answer0/263ms6248 KiB
20Wrong answer0/157ms6176 KiB
21Time limit exceeded0/2363ms4268 KiB
22Wrong answer0/246ms6452 KiB
23Wrong answer0/256ms6508 KiB