Submission #416300

#TimeUsernameProblemLanguageResultExecution timeMemory
416300Runtime_error_Money (IZhO17_money)C++14
100 / 100
1374 ms51400 KiB
#include <bits/stdc++.h> using namespace std; const int inf = 1e6+9; int n,ans,a[inf]; set<int> s; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); int pt = 1; while(pt <= n){ int mn = inf,mx = 0,i,pre = 0; for(i=pt;i<=n;i++){ if(a[i] < pre) break; mn = min(mn,a[i]); mx = max(mx,a[i]); pre = a[i]; if(s.empty() || *s.begin() >= mx || *s.rbegin() <= mn || *s.upper_bound(mn) >= mx) continue; break; } ans++; for(int j=pt;j<i;j++) s.insert(a[j]); pt = i; } printf("%d\n",ans); } /* 4 1 4 2 5 6 3 6 4 5 1 2 */

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         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...