# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127580 | 2019-07-09T15:29:02 Z | MohamedAhmed04 | Bali Sculptures (APIO15_sculpture) | C++14 | 14 ms | 9468 KB |
#include <bits/stdc++.h> using namespace std; const int MAX = 2005 ; const int MAX2 = 105 ; long long arr[MAX] , pref[MAX]; long long dp[MAX2][MAX2][MAX2] ; int n , a , b ; long long now = 0 ; long long calc1(int idx , int st , int groups) { if(idx == n && groups >= a && groups <= b) { long long val ; if(st == 0) val = pref[idx-1] ; else val = pref[idx-1] - pref[st-1] ; return val ; } if(idx == n && groups < a || groups > b) return (1ll << 58) ; long long &ret = dp[idx][st][groups] ; if(ret != -1) return ret ; long long val ; if(st == 0) val = pref[idx-1] ; else val = pref[idx-1] - pref[st-1] ; long long choice1 = calc1(idx+1 , st , groups) ; long long choice2 = calc1(idx+1 , idx , groups+1) | val ; ret = min(choice1 , choice2) ; return ret ; } void solve1() { memset(dp , -1 , sizeof(dp)) ; cout<<calc1(1 , 0 , 1)<<"\n" ; return ; } //void solve2() //{ // //} int main() { scanf("%d %d %d" , &n , &a , &b) ; for(int i = 0 ; i < n ; ++i) scanf("%lld" , &arr[i]) ; pref[0] = arr[0] ; for(int i = 1 ; i < n ; ++i) pref[i] = pref[i-1] + arr[i] ; if(n <= 100) { solve1() ; return 0 ; } //solve2() ; return 0 ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 9464 KB | Output is correct |
2 | Correct | 9 ms | 9336 KB | Output is correct |
3 | Correct | 9 ms | 9464 KB | Output is correct |
4 | Correct | 9 ms | 9336 KB | Output is correct |
5 | Correct | 9 ms | 9464 KB | Output is correct |
6 | Correct | 9 ms | 9464 KB | Output is correct |
7 | Correct | 9 ms | 9336 KB | Output is correct |
8 | Correct | 9 ms | 9336 KB | Output is correct |
9 | Correct | 10 ms | 9468 KB | Output is correct |
10 | Correct | 9 ms | 9336 KB | Output is correct |
11 | Correct | 9 ms | 9464 KB | Output is correct |
12 | Correct | 9 ms | 9336 KB | Output is correct |
13 | Correct | 9 ms | 9464 KB | Output is correct |
14 | Correct | 9 ms | 9464 KB | Output is correct |
15 | Correct | 9 ms | 9336 KB | Output is correct |
16 | Correct | 10 ms | 9336 KB | Output is correct |
17 | Correct | 9 ms | 9464 KB | Output is correct |
18 | Correct | 9 ms | 9464 KB | Output is correct |
19 | Correct | 10 ms | 9340 KB | Output is correct |
20 | Correct | 9 ms | 9464 KB | Output is correct |
21 | Incorrect | 9 ms | 9336 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 9436 KB | Output is correct |
2 | Correct | 9 ms | 9464 KB | Output is correct |
3 | Correct | 10 ms | 9464 KB | Output is correct |
4 | Correct | 9 ms | 9336 KB | Output is correct |
5 | Correct | 9 ms | 9336 KB | Output is correct |
6 | Correct | 9 ms | 9464 KB | Output is correct |
7 | Correct | 9 ms | 9464 KB | Output is correct |
8 | Correct | 10 ms | 9464 KB | Output is correct |
9 | Correct | 9 ms | 9336 KB | Output is correct |
10 | Correct | 9 ms | 9336 KB | Output is correct |
11 | Correct | 9 ms | 9336 KB | Output is correct |
12 | Correct | 10 ms | 9312 KB | Output is correct |
13 | Correct | 9 ms | 9464 KB | Output is correct |
14 | Correct | 9 ms | 9464 KB | Output is correct |
15 | Correct | 9 ms | 9336 KB | Output is correct |
16 | Correct | 10 ms | 9464 KB | Output is correct |
17 | Correct | 9 ms | 9464 KB | Output is correct |
18 | Correct | 9 ms | 9336 KB | Output is correct |
19 | Correct | 9 ms | 9336 KB | Output is correct |
20 | Correct | 9 ms | 9464 KB | Output is correct |
21 | Incorrect | 9 ms | 9340 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 9336 KB | Output is correct |
2 | Correct | 9 ms | 9464 KB | Output is correct |
3 | Correct | 9 ms | 9464 KB | Output is correct |
4 | Correct | 10 ms | 9408 KB | Output is correct |
5 | Correct | 9 ms | 9464 KB | Output is correct |
6 | Correct | 11 ms | 9336 KB | Output is correct |
7 | Correct | 11 ms | 9336 KB | Output is correct |
8 | Correct | 11 ms | 9336 KB | Output is correct |
9 | Correct | 12 ms | 9336 KB | Output is correct |
10 | Correct | 11 ms | 9336 KB | Output is correct |
11 | Correct | 10 ms | 9380 KB | Output is correct |
12 | Correct | 9 ms | 9336 KB | Output is correct |
13 | Correct | 9 ms | 9464 KB | Output is correct |
14 | Correct | 9 ms | 9464 KB | Output is correct |
15 | Correct | 10 ms | 9336 KB | Output is correct |
16 | Correct | 9 ms | 9336 KB | Output is correct |
17 | Correct | 10 ms | 9308 KB | Output is correct |
18 | Correct | 10 ms | 9336 KB | Output is correct |
19 | Correct | 10 ms | 9336 KB | Output is correct |
20 | Correct | 9 ms | 9464 KB | Output is correct |
21 | Correct | 10 ms | 9336 KB | Output is correct |
22 | Correct | 10 ms | 9464 KB | Output is correct |
23 | Correct | 10 ms | 9464 KB | Output is correct |
24 | Correct | 10 ms | 9464 KB | Output is correct |
25 | Correct | 10 ms | 9464 KB | Output is correct |
26 | Correct | 11 ms | 9336 KB | Output is correct |
27 | Correct | 12 ms | 9436 KB | Output is correct |
28 | Correct | 14 ms | 9436 KB | Output is correct |
29 | Correct | 14 ms | 9380 KB | Output is correct |
30 | Correct | 9 ms | 9336 KB | Output is correct |
31 | Correct | 13 ms | 9336 KB | Output is correct |
32 | Correct | 14 ms | 9464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9336 KB | Output is correct |
2 | Correct | 9 ms | 9464 KB | Output is correct |
3 | Correct | 9 ms | 9336 KB | Output is correct |
4 | Correct | 9 ms | 9464 KB | Output is correct |
5 | Correct | 10 ms | 9464 KB | Output is correct |
6 | Correct | 10 ms | 9468 KB | Output is correct |
7 | Correct | 10 ms | 9340 KB | Output is correct |
8 | Correct | 9 ms | 9336 KB | Output is correct |
9 | Correct | 9 ms | 9336 KB | Output is correct |
10 | Correct | 10 ms | 9336 KB | Output is correct |
11 | Correct | 11 ms | 9336 KB | Output is correct |
12 | Correct | 10 ms | 9336 KB | Output is correct |
13 | Correct | 12 ms | 9464 KB | Output is correct |
14 | Correct | 11 ms | 9336 KB | Output is correct |
15 | Correct | 11 ms | 9464 KB | Output is correct |
16 | Correct | 9 ms | 9396 KB | Output is correct |
17 | Correct | 9 ms | 9464 KB | Output is correct |
18 | Correct | 9 ms | 9336 KB | Output is correct |
19 | Correct | 9 ms | 9336 KB | Output is correct |
20 | Correct | 9 ms | 9336 KB | Output is correct |
21 | Incorrect | 10 ms | 9464 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9464 KB | Output is correct |
2 | Correct | 10 ms | 9340 KB | Output is correct |
3 | Correct | 9 ms | 9336 KB | Output is correct |
4 | Correct | 9 ms | 9464 KB | Output is correct |
5 | Correct | 9 ms | 9336 KB | Output is correct |
6 | Correct | 10 ms | 9464 KB | Output is correct |
7 | Correct | 9 ms | 9336 KB | Output is correct |
8 | Correct | 10 ms | 9464 KB | Output is correct |
9 | Correct | 11 ms | 9420 KB | Output is correct |
10 | Correct | 10 ms | 9464 KB | Output is correct |
11 | Correct | 9 ms | 9336 KB | Output is correct |
12 | Correct | 9 ms | 9336 KB | Output is correct |
13 | Correct | 10 ms | 9412 KB | Output is correct |
14 | Correct | 11 ms | 9336 KB | Output is correct |
15 | Correct | 9 ms | 9336 KB | Output is correct |
16 | Correct | 10 ms | 9336 KB | Output is correct |
17 | Correct | 11 ms | 9336 KB | Output is correct |
18 | Incorrect | 10 ms | 9464 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |