Submission #341451

#TimeUsernameProblemLanguageResultExecution timeMemory
341451katearimaMoney (IZhO17_money)C++14
100 / 100
1457 ms58220 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e6+5; int n,t,ans, a[N], mn,mx; set <int> st; set<int>::iterator itr; main(){ cin>>n; mn=1e6+4; for(int i=0; i<n; i++){ cin>>a[i]; mx=max(mx, a[i]); mn=min(mn, a[i]); } mn--; mx++; //cout<<mn<<" "<<mx<<endl; st.insert(mn); st.insert(mx); for(int i=0; i<n; i++){ bool tr=false; st.insert(a[i]); int k=*st.upper_bound(a[i]); while(a[i]<=a[i+1] && a[i+1]<=k){ st.insert(a[i+1]); i++; tr=true; } //if(tr) i--; //cout<<i<<" "<<a[i]<<endl; ans++; } cout<<ans<<endl; }

Compilation message (stderr)

money.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      |      ^
money.cpp: In function 'int main()':
money.cpp:19:18: warning: variable 'tr' set but not used [-Wunused-but-set-variable]
   19 |             bool tr=false;
      |                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...