Submission #910271

#TimeUsernameProblemLanguageResultExecution timeMemory
910271vjudge1Money (IZhO17_money)C++17
0 / 100
1 ms2396 KiB
/*#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2,fma")*/ #include <bits/stdc++.h> using namespace std; #define ll long long int ll n,m,k,cnt; ll a[1000010]; ll mp[1000010]; void anomalous_solve() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; mp[a[i]]=i; } ll ans=0; mp[0]=100000000; for(int i=1;i<=n;i++) { //cout<<i<<" "; if(mp[i]-1==mp[i-1]) { //cout<<ans<<"\n"; continue; } else { if(a[mp[i]-1]<i && mp[a[mp[i]-1]]+1==mp[i]) { //cout<<ans<<"\n"; continue; } ans++;//cout<<ans<<"\n"; } } cout<<ans; } int main() { // freopen("INPUT.txt","r",stdin); // freopen("OUTPUT.txt","w",stdout); ios_base::sync_with_stdio(); cin.tie(NULL); cout.tie(NULL); ll test=1; //cin>>test; for(int pos=1;pos<=test;pos++) anomalous_solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...