# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
570256 |
2022-05-28T23:30:04 Z |
gg123_pe |
Money (IZhO17_money) |
C++14 |
|
1 ms |
212 KB |
#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
money.cpp: In function 'int main()':
money.cpp:27:13: warning: unused variable 'maxi' [-Wunused-variable]
27 | int maxi = *s.rbegin();
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |