Submission #35187

#TimeUsernameProblemLanguageResultExecution timeMemory
35187ulnaMoney (IZhO17_money)C++11
45 / 100
1500 ms52784 KiB
#include <bits/stdc++.h> using namespace std; // why am I so weak int n; int a[1000055]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } set<int> s; s.insert(0), s.insert((int)1e7); int lb = 0, ub = (int)1e7; int res = 1; for (int i = 0; i < n; i++) { if (lb <= a[i] && a[i] <= ub) { s.insert(a[i]); lb = a[i]; continue; } lb = a[i]; ub = *s.upper_bound(a[i]); res++; s.insert(a[i]); } printf("%d\n", res); return 0; }

Compilation message (stderr)

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