# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1092043 |
2024-09-23T03:00:30 Z |
juicy |
Money (IZhO17_money) |
C++17 |
|
0 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e6 + 5, inf = 1e9;
int n;
int a[N], nxt[N], f[N];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
for (int i = n; i >= 1; --i) {
nxt[i] = a[i] <= a[i + 1] ? nxt[i + 1] : i;
}
set<int> st{0, inf};
fill(f + 1, f + n + 1, inf);
for (int i = 1; i <= n; ++i) {
int x = *st.upper_bound(a[i]);
int l = i + 1, r = nxt[i], p = i;
while (l <= r) {
int m = (l + r) / 2;
if (a[m] <= x) {
p = m;
l = m + 1;
} else {
r = m - 1;
}
}
f[p] = min(f[p], f[i - 1] + 1);
}
cout << f[n];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |