# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
901520 |
2024-01-09T13:59:56 Z |
OAleksa |
Money (IZhO17_money) |
C++14 |
|
1 ms |
2396 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int N = 1e6 + 69;
int n, a[N], dp[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++) {
cin >> a[i];
dp[i] = 1e9;
}
set<int> st;
dp[0] = 0;
st.insert(0);
st.insert(1e9);
for (int i = 1;i <= n;i++) {
dp[i] = min(dp[i], dp[i - 1] + 1);
for (auto u = st.begin();u != st.end();u++) {
auto t = u;
++t;
int x = *u, y = *t;
int j = i + 1;
while (j <= n && a[j] >= x && a[j] <= y && a[j] >= a[j - 1])
j++;
for (int k = i;k < j;k++)
dp[k] = min(dp[k], dp[i - 1] + 1);
}
st.insert(a[i]);
}
cout << dp[n];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |