# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
35054 |
2017-11-17T20:25:50 Z |
model_code |
Money (IZhO17_money) |
C++14 |
|
116 ms |
3188 KB |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
using namespace std;
const int N = int(3e5), mod = int(1e9) + 7;
int n, a[N];
bool check(int l,int r){
for(int i = l + 1; i <= r; i++){
if(a[i] < a[i - 1]) return 0;
}
for(int i = 0; i < l; i++){
if(a[i] > a[l] && a[i] < a[r]) return 0;
}
return 1;
}
int main () {
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
int ans = N;
for(int mask = 0; mask < (1<<n); mask++){
if(!(mask & 1<<(n - 1))) continue;
int last = 0;
bool ok = 1;
for(int i = 0; i < n; i++){
if(mask & (1<<i)){
if(!check(last, i)) ok = 0;
last = i + 1;
}
}
if(ok) ans = min(ans, __builtin_popcount(mask));
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3188 KB |
Output is correct |
2 |
Correct |
0 ms |
3188 KB |
Output is correct |
3 |
Correct |
0 ms |
3188 KB |
Output is correct |
4 |
Correct |
0 ms |
3188 KB |
Output is correct |
5 |
Correct |
0 ms |
3188 KB |
Output is correct |
6 |
Correct |
0 ms |
3188 KB |
Output is correct |
7 |
Correct |
0 ms |
3188 KB |
Output is correct |
8 |
Correct |
0 ms |
3188 KB |
Output is correct |
9 |
Correct |
0 ms |
3188 KB |
Output is correct |
10 |
Correct |
0 ms |
3188 KB |
Output is correct |
11 |
Correct |
0 ms |
3188 KB |
Output is correct |
12 |
Correct |
0 ms |
3188 KB |
Output is correct |
13 |
Correct |
0 ms |
3188 KB |
Output is correct |
14 |
Correct |
0 ms |
3188 KB |
Output is correct |
15 |
Correct |
0 ms |
3188 KB |
Output is correct |
16 |
Correct |
0 ms |
3188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3188 KB |
Output is correct |
2 |
Correct |
0 ms |
3188 KB |
Output is correct |
3 |
Correct |
0 ms |
3188 KB |
Output is correct |
4 |
Correct |
0 ms |
3188 KB |
Output is correct |
5 |
Correct |
0 ms |
3188 KB |
Output is correct |
6 |
Correct |
0 ms |
3188 KB |
Output is correct |
7 |
Correct |
0 ms |
3188 KB |
Output is correct |
8 |
Correct |
0 ms |
3188 KB |
Output is correct |
9 |
Correct |
0 ms |
3188 KB |
Output is correct |
10 |
Correct |
0 ms |
3188 KB |
Output is correct |
11 |
Correct |
0 ms |
3188 KB |
Output is correct |
12 |
Correct |
0 ms |
3188 KB |
Output is correct |
13 |
Correct |
0 ms |
3188 KB |
Output is correct |
14 |
Correct |
0 ms |
3188 KB |
Output is correct |
15 |
Correct |
0 ms |
3188 KB |
Output is correct |
16 |
Correct |
0 ms |
3188 KB |
Output is correct |
17 |
Correct |
3 ms |
3188 KB |
Output is correct |
18 |
Correct |
0 ms |
3188 KB |
Output is correct |
19 |
Correct |
0 ms |
3188 KB |
Output is correct |
20 |
Correct |
113 ms |
3188 KB |
Output is correct |
21 |
Correct |
109 ms |
3188 KB |
Output is correct |
22 |
Correct |
116 ms |
3188 KB |
Output is correct |
23 |
Correct |
109 ms |
3188 KB |
Output is correct |
24 |
Correct |
113 ms |
3188 KB |
Output is correct |
25 |
Correct |
96 ms |
3188 KB |
Output is correct |
26 |
Correct |
103 ms |
3188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3188 KB |
Output is correct |
2 |
Correct |
0 ms |
3188 KB |
Output is correct |
3 |
Correct |
0 ms |
3188 KB |
Output is correct |
4 |
Correct |
0 ms |
3188 KB |
Output is correct |
5 |
Correct |
0 ms |
3188 KB |
Output is correct |
6 |
Correct |
0 ms |
3188 KB |
Output is correct |
7 |
Correct |
0 ms |
3188 KB |
Output is correct |
8 |
Correct |
0 ms |
3188 KB |
Output is correct |
9 |
Correct |
0 ms |
3188 KB |
Output is correct |
10 |
Correct |
0 ms |
3188 KB |
Output is correct |
11 |
Correct |
0 ms |
3188 KB |
Output is correct |
12 |
Correct |
0 ms |
3188 KB |
Output is correct |
13 |
Correct |
0 ms |
3188 KB |
Output is correct |
14 |
Correct |
0 ms |
3188 KB |
Output is correct |
15 |
Correct |
0 ms |
3188 KB |
Output is correct |
16 |
Correct |
0 ms |
3188 KB |
Output is correct |
17 |
Correct |
3 ms |
3188 KB |
Output is correct |
18 |
Correct |
0 ms |
3188 KB |
Output is correct |
19 |
Correct |
0 ms |
3188 KB |
Output is correct |
20 |
Correct |
113 ms |
3188 KB |
Output is correct |
21 |
Correct |
109 ms |
3188 KB |
Output is correct |
22 |
Correct |
116 ms |
3188 KB |
Output is correct |
23 |
Correct |
109 ms |
3188 KB |
Output is correct |
24 |
Correct |
113 ms |
3188 KB |
Output is correct |
25 |
Correct |
96 ms |
3188 KB |
Output is correct |
26 |
Correct |
103 ms |
3188 KB |
Output is correct |
27 |
Incorrect |
0 ms |
3188 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3188 KB |
Output is correct |
2 |
Correct |
0 ms |
3188 KB |
Output is correct |
3 |
Correct |
0 ms |
3188 KB |
Output is correct |
4 |
Correct |
0 ms |
3188 KB |
Output is correct |
5 |
Correct |
0 ms |
3188 KB |
Output is correct |
6 |
Correct |
0 ms |
3188 KB |
Output is correct |
7 |
Correct |
0 ms |
3188 KB |
Output is correct |
8 |
Correct |
0 ms |
3188 KB |
Output is correct |
9 |
Correct |
0 ms |
3188 KB |
Output is correct |
10 |
Correct |
0 ms |
3188 KB |
Output is correct |
11 |
Correct |
0 ms |
3188 KB |
Output is correct |
12 |
Correct |
0 ms |
3188 KB |
Output is correct |
13 |
Correct |
0 ms |
3188 KB |
Output is correct |
14 |
Correct |
0 ms |
3188 KB |
Output is correct |
15 |
Correct |
0 ms |
3188 KB |
Output is correct |
16 |
Correct |
0 ms |
3188 KB |
Output is correct |
17 |
Correct |
3 ms |
3188 KB |
Output is correct |
18 |
Correct |
0 ms |
3188 KB |
Output is correct |
19 |
Correct |
0 ms |
3188 KB |
Output is correct |
20 |
Correct |
113 ms |
3188 KB |
Output is correct |
21 |
Correct |
109 ms |
3188 KB |
Output is correct |
22 |
Correct |
116 ms |
3188 KB |
Output is correct |
23 |
Correct |
109 ms |
3188 KB |
Output is correct |
24 |
Correct |
113 ms |
3188 KB |
Output is correct |
25 |
Correct |
96 ms |
3188 KB |
Output is correct |
26 |
Correct |
103 ms |
3188 KB |
Output is correct |
27 |
Incorrect |
0 ms |
3188 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |