Submission #92660

#TimeUsernameProblemLanguageResultExecution timeMemory
92660GioChkhaidzeMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; int n,a[1000006],f[1000006],fix[1000006],Ans; set < int > st; void go(int x,int idx) { int ko=0; Ans++; fix[x]=1; st.insert(x); for (int i=idx+1; i<=n; i++) { if (fix[a[i]] || a[i]<x) break; if (st.upper_bound(x)==st.end() || a[i]<=*st.upper_bound(x)) { fix[a[i]]=1; st.insert(a[i]); x=a[i]; } else break; } } main () { ios::sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) { cin>>a[i]; f[a[i]]=i; } for (int i=1; i<=n; i++) if (!fix[i]) go(i,f[i]); cout<<Ans<<endl; }

Compilation message (stderr)

money.cpp: In function 'void go(int, int)':
money.cpp:9:6: warning: unused variable 'ko' [-Wunused-variable]
  int ko=0;
      ^~
money.cpp: At global scope:
money.cpp:30:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main ()
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...