# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
758087 |
2023-06-14T06:52:33 Z |
vjudge1 |
Money (IZhO17_money) |
C++17 |
|
1 ms |
468 KB |
#include"bits/stdc++.h"
using namespace std;
#define ll long long
const ll mod = 1000000007;
int b[1000001];
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];
int ans = n;
for(int i = 0; i < (1 << n); i++) {
b[1] = 1e6;
set<int> s;
s.insert(-1);
bool bad = 0;
int cur = 0;
for(int j = 0; j < n; j++) {
int l = j, r;
for(int k = j; k < n; k++) {
r = k;
if(k - 1 >= j && a[k] < a[k - 1])
bad = 1;
if(i & (1 << k))
break;
}
int g = *s.lower_bound(-a[j]) * -1;
if(a[r] > b[g])
bad = 1;
if(bad)
break;
b[a[r]] = b[g];
b[g] = a[l];
s.insert(-a[r]);
s.insert(-g);
for(int k = l; k < r; k++) {
b[a[k]] = a[k + 1];
s.insert(-a[k]);
}
cur++;
j = r;
}
if(!bad)
ans = min(ans, cur);
while(s.size()) {
b[*s.begin()] = 0;
s.erase(s.begin());
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
8 |
Halted |
0 ms |
0 KB |
- |