Submission #35150

#TimeUsernameProblemLanguageResultExecution timeMemory
35150PajarajaMoney (IZhO17_money)C++14
100 / 100
303 ms9828 KiB
#include <bits/stdc++.h> using namespace std; int bit[1000007],a[1000007],n; void upd(int x) { while(x<=1000000) { bit[x]++; x+=(x&-x); } } int sum(int x) { int s=0; while(x>0) { s+=bit[x]; x-=(x&-x); } return s; } bool ima(int l,int r) {return sum(r-1)>sum(l);} int main() { int cnt=1,last=0; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=1;i<n;i++) { if(a[i]<a[i-1] || ima(a[last],a[i])) { cnt++; while(last<i) upd(a[last++]); } } printf("%d",cnt); }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:26:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
money.cpp:27:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;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...