# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39377 | 2018-01-13T10:30:53 Z | Extazy | Money (IZhO17_money) | C++14 | 0 ms | 10968 KB |
#include <bits/stdc++.h> #define endl '\n' using namespace std; const int N = 1000007; int n,a[N]; bool used[N]; int state[N]; multiset < int >::iterator prev(multiset < int >::iterator it) { --it; return it; } bool are_consecutive(multiset < int > &s, int v1, int v2) { if(v1==v2) return true; return *prev(s.lower_bound(v2))==v1; } int recurse(int pos) { if(pos<1) return 0; if(used[pos]) return state[pos]; used[pos]=true; int i,ans=recurse(pos-1)+1; multiset < int > s; for(i=1;i<=pos;i++) s.insert(a[i]); for(i=pos-1;i>=1;i--) { if(!are_consecutive(s,a[i],a[i+1])) break; ans=min(ans,1+recurse(i-1)); } return state[pos]=ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d", &a[i]); } printf("%d\n", recurse(n)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10968 KB | Output is correct |
2 | Correct | 0 ms | 10968 KB | Output is correct |
3 | Correct | 0 ms | 10968 KB | Output is correct |
4 | Correct | 0 ms | 10968 KB | Output is correct |
5 | Correct | 0 ms | 10968 KB | Output is correct |
6 | Correct | 0 ms | 10968 KB | Output is correct |
7 | Correct | 0 ms | 10968 KB | Output is correct |
8 | Correct | 0 ms | 10968 KB | Output is correct |
9 | Correct | 0 ms | 10968 KB | Output is correct |
10 | Correct | 0 ms | 10968 KB | Output is correct |
11 | Correct | 0 ms | 10968 KB | Output is correct |
12 | Incorrect | 0 ms | 10968 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10968 KB | Output is correct |
2 | Correct | 0 ms | 10968 KB | Output is correct |
3 | Correct | 0 ms | 10968 KB | Output is correct |
4 | Correct | 0 ms | 10968 KB | Output is correct |
5 | Correct | 0 ms | 10968 KB | Output is correct |
6 | Correct | 0 ms | 10968 KB | Output is correct |
7 | Correct | 0 ms | 10968 KB | Output is correct |
8 | Correct | 0 ms | 10968 KB | Output is correct |
9 | Correct | 0 ms | 10968 KB | Output is correct |
10 | Correct | 0 ms | 10968 KB | Output is correct |
11 | Correct | 0 ms | 10968 KB | Output is correct |
12 | Incorrect | 0 ms | 10968 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10968 KB | Output is correct |
2 | Correct | 0 ms | 10968 KB | Output is correct |
3 | Correct | 0 ms | 10968 KB | Output is correct |
4 | Correct | 0 ms | 10968 KB | Output is correct |
5 | Correct | 0 ms | 10968 KB | Output is correct |
6 | Correct | 0 ms | 10968 KB | Output is correct |
7 | Correct | 0 ms | 10968 KB | Output is correct |
8 | Correct | 0 ms | 10968 KB | Output is correct |
9 | Correct | 0 ms | 10968 KB | Output is correct |
10 | Correct | 0 ms | 10968 KB | Output is correct |
11 | Correct | 0 ms | 10968 KB | Output is correct |
12 | Incorrect | 0 ms | 10968 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 10968 KB | Output is correct |
2 | Correct | 0 ms | 10968 KB | Output is correct |
3 | Correct | 0 ms | 10968 KB | Output is correct |
4 | Correct | 0 ms | 10968 KB | Output is correct |
5 | Correct | 0 ms | 10968 KB | Output is correct |
6 | Correct | 0 ms | 10968 KB | Output is correct |
7 | Correct | 0 ms | 10968 KB | Output is correct |
8 | Correct | 0 ms | 10968 KB | Output is correct |
9 | Correct | 0 ms | 10968 KB | Output is correct |
10 | Correct | 0 ms | 10968 KB | Output is correct |
11 | Correct | 0 ms | 10968 KB | Output is correct |
12 | Incorrect | 0 ms | 10968 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |