20672022-12-16 09:19:07kohumarkRendezéscpp11Wrong answer 5/40212ms13680 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 m1, m2;
    set<int> r;
    int s[n]; bool ok=true;
    for(int i=0; i<n; i++) cin >> s[i];
    for(int i=0; i<m; i++){
        cin >> m1 >> m2;
        for(int j=m1-1; j<m2; j++) r.insert(j);
    }
    int a=-1;
    for(int i=0; i<n; i++){
        if(r.count(i)&&a==-1) a=i;
        if(!r.count(i)&&a!=-1){sort(s+a, s+i); a=-1;}
    }
    if(r.count(n-1)&&a!=-1) sort(s+a, s+n);
    int j=0;
    for(int i=0; i<n; i++) if(s[i]==i+1) j++;
    cout << j;
}
SubtaskSumTestVerdictTimeMemory
base5/40
1Accepted0/03ms1832 KiB
2Wrong answer0/010ms2528 KiB
3Wrong answer0/22ms2228 KiB
4Wrong answer0/22ms2204 KiB
5Wrong answer0/22ms2328 KiB
6Wrong answer0/22ms2532 KiB
7Wrong answer0/23ms2652 KiB
8Wrong answer0/23ms2700 KiB
9Wrong answer0/23ms2648 KiB
10Wrong answer0/23ms2908 KiB
11Wrong answer0/282ms10224 KiB
12Wrong answer0/279ms9748 KiB
13Wrong answer0/281ms10060 KiB
14Wrong answer0/179ms10180 KiB
15Wrong answer0/282ms10232 KiB
16Wrong answer0/2149ms13560 KiB
17Accepted2/2187ms13636 KiB
18Wrong answer0/2192ms13680 KiB
19Wrong answer0/2188ms13420 KiB
20Accepted1/1182ms13532 KiB
21Accepted2/2212ms13552 KiB
22Wrong answer0/2160ms13296 KiB
23Wrong answer0/2167ms13560 KiB