Submission #545171

#TimeUsernameProblemLanguageResultExecution timeMemory
545171krit3379Money (IZhO17_money)C++17
100 / 100
1073 ms58092 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 1000005 int a[N],ma,ans; set<int> s; int main(){ int n,i; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&a[i]); s.insert(N); ma=N; ans=1; for(i=1;i<=n;i++){ if(a[i]==a[i-1])continue; auto it=s.lower_bound(a[i]); if(a[i]<a[i-1]||ma!=*it){ ans++; ma=*s.upper_bound(a[i]); } s.insert(a[i]); } printf("%d",ans); return 0; }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(i=1;i<=n;i++)scanf("%d",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...