Submission #570256

#TimeUsernameProblemLanguageResultExecution timeMemory
570256gg123_peMoney (IZhO17_money)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define f(i,a,b) for(int i = a; i < b; i++) const int N = 1e6 + 6; int n, a[N], dp[N]; set <int> s; int main(){ cin >> n; f(i,1,n+1) cin >> a[i]; a[n+1] = N; int id = 0; s.insert(0); f(i,1,n+1){ dp[i] = 1; if(a[i] > a[i+1]) break; } while(id <= n){ while(id <= n and a[id] <= a[id+1]) s.insert(a[id]), id++; id++; int maxi = *s.rbegin(); f(i,id,n+1){ auto it = s.lower_bound(a[i]); it = prev(it); int x = *it, j; j = lower_bound(a+id,a+i+1,x) - a; dp[i] = dp[j-1] + 1; if(a[i] > a[i+1]) break; } } cout << dp[n] << "\n"; return 0; }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:27:13: warning: unused variable 'maxi' [-Wunused-variable]
   27 |         int maxi = *s.rbegin();
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...