7197 | 2024-01-03 12:42:04 | horvathabel | Rendezés | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int k;
cin>>k;
vector<int> pre;
vector<int> v;
pre.resize(n+1,0);
for (int i=0; i<n;i++){
int x;a
cin>>x;
v.push_back(x);
}
for (int i=0; i<k;i++){
int a,b;
cin>>a>>b;
a--;
b--;
pre[a]++;
pre[b]--;
}
int ke=-1;
int most=0;
for (int i=0; i<n;i++){
most+=pre[i];
if (ke==-1 && most>0){
ke=i;
}
if (most==0 && ke!=-1){
sort(v.begin()+ke, v.begin()+i+1);
ke=-1;
}
}
int ans=0;
for (int i=0; i<n;i++){
ans+=(v[i]==i+1);
}
cout<<ans<<endl;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:14:15: error: 'a' was not declared in this scope
14 | int x;a
| ^
Exited with error status 1