Submission #910407

#TimeUsernameProblemLanguageResultExecution timeMemory
910407vjudge1Money (IZhO17_money)C++17
0 / 100
1 ms4444 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]; ll tek[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; vector<ll>v; for(int i=1;i<=n;i++) { //cout<<i<<" "; v.push_back(i); if(mp[i]-1==mp[i-1]) { //cout<<ans<<"!\n"; continue; } else { //cout<<a[mp[i]-1]<<" "<<mp[a[mp[i]-1]]+1<<" "<<tek[a[mp[i]-1]]<<"___"; if(a[mp[i]-1]<i && mp[a[mp[i]-1]]+1==mp[i] && tek[a[mp[i]-1]]==0) { //cout<<ans<<"?\n"; for(int j=a[mp[i]-1];j<i;j++) { tek[j]=1; } 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...