# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
597248 | 2022-07-15T19:34:55 Z | Belphegor | Bali Sculptures (APIO15_sculpture) | C++14 | 265 ms | 2516 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n,a,b; ll arr[105]; ll subtask1(){ ll ans = INT64_MAX; for(int i=1; i<(1<<n); i++){ vector<int>v; for(int j=0; j<n; j++) if(i&(1<<j)) v.emplace_back(j); if(v.back()!=n-1) continue; if(v.size()<a || v.size()>b) continue; ll ret = 0; for(int j=0; j<=v[0]; j++) ret+=arr[j]; for(int j=1; j<v.size(); j++){ ll sum = 0; for(int k=v[j-1]+1; k<=v[j]; k++) sum+=arr[k]; ret|=sum; } ans = min(ans,ret); } return ans; } int dp[55][22][1005]; int subtask2(){ for(int i=n; i>=1; i--) arr[i] = arr[i-1]; arr[0] = 0; for(int i=1; i<=n; i++) arr[i]+=arr[i-1]; dp[0][0][0] = 1; int ret = arr[n]; for(int i=0; i<=n; i++){ for(int j=0; j<n; j++){ for(int val = 0; val<=arr[n]; val++){ if(!dp[i][j][val]) continue; for(int k=j+1; k<=n; k++){ int v = val | (arr[k]-arr[j]); dp[i+1][k][v] = 1; } } } if(a<=i && i<=b){ for(int j=0; j<=arr[n]; j++){ if(dp[i][n][j]) ret = min(ret,j); } } } return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>a>>b; for(int i=0; i<n; i++) cin>>arr[i]; if(n<=20) cout<<subtask1(); else cout<<subtask2(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 24 ms | 320 KB | Output is correct |
8 | Correct | 204 ms | 312 KB | Output is correct |
9 | Correct | 205 ms | 312 KB | Output is correct |
10 | Correct | 201 ms | 212 KB | Output is correct |
11 | Correct | 201 ms | 312 KB | Output is correct |
12 | Correct | 209 ms | 316 KB | Output is correct |
13 | Correct | 231 ms | 300 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 6 ms | 212 KB | Output is correct |
20 | Correct | 24 ms | 328 KB | Output is correct |
21 | Correct | 249 ms | 304 KB | Output is correct |
22 | Correct | 207 ms | 332 KB | Output is correct |
23 | Correct | 209 ms | 304 KB | Output is correct |
24 | Correct | 230 ms | 312 KB | Output is correct |
25 | Correct | 222 ms | 304 KB | Output is correct |
26 | Correct | 226 ms | 308 KB | Output is correct |
27 | Correct | 0 ms | 212 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 3 ms | 212 KB | Output is correct |
30 | Correct | 101 ms | 308 KB | Output is correct |
31 | Correct | 211 ms | 212 KB | Output is correct |
32 | Correct | 211 ms | 312 KB | Output is correct |
33 | Correct | 237 ms | 308 KB | Output is correct |
34 | Correct | 230 ms | 304 KB | Output is correct |
35 | Correct | 220 ms | 308 KB | Output is correct |
36 | Correct | 260 ms | 308 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 26 ms | 332 KB | Output is correct |
8 | Correct | 199 ms | 312 KB | Output is correct |
9 | Correct | 226 ms | 312 KB | Output is correct |
10 | Correct | 200 ms | 332 KB | Output is correct |
11 | Correct | 206 ms | 308 KB | Output is correct |
12 | Correct | 233 ms | 308 KB | Output is correct |
13 | Correct | 246 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 7 ms | 212 KB | Output is correct |
20 | Correct | 28 ms | 212 KB | Output is correct |
21 | Correct | 209 ms | 312 KB | Output is correct |
22 | Correct | 215 ms | 312 KB | Output is correct |
23 | Correct | 206 ms | 304 KB | Output is correct |
24 | Correct | 205 ms | 324 KB | Output is correct |
25 | Correct | 208 ms | 312 KB | Output is correct |
26 | Correct | 237 ms | 304 KB | Output is correct |
27 | Correct | 1 ms | 1236 KB | Output is correct |
28 | Incorrect | 3 ms | 2516 KB | Output isn't correct |
29 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 24 ms | 212 KB | Output is correct |
8 | Correct | 204 ms | 308 KB | Output is correct |
9 | Correct | 218 ms | 312 KB | Output is correct |
10 | Correct | 206 ms | 332 KB | Output is correct |
11 | Correct | 199 ms | 304 KB | Output is correct |
12 | Correct | 223 ms | 324 KB | Output is correct |
13 | Correct | 231 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 1236 KB | Output is correct |
15 | Incorrect | 3 ms | 2516 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 9 ms | 212 KB | Output is correct |
7 | Correct | 31 ms | 212 KB | Output is correct |
8 | Correct | 201 ms | 308 KB | Output is correct |
9 | Correct | 222 ms | 308 KB | Output is correct |
10 | Correct | 215 ms | 308 KB | Output is correct |
11 | Correct | 201 ms | 308 KB | Output is correct |
12 | Correct | 263 ms | 212 KB | Output is correct |
13 | Correct | 227 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 224 KB | Output is correct |
19 | Correct | 7 ms | 332 KB | Output is correct |
20 | Correct | 25 ms | 212 KB | Output is correct |
21 | Correct | 240 ms | 300 KB | Output is correct |
22 | Correct | 204 ms | 308 KB | Output is correct |
23 | Correct | 208 ms | 304 KB | Output is correct |
24 | Correct | 217 ms | 332 KB | Output is correct |
25 | Correct | 197 ms | 312 KB | Output is correct |
26 | Correct | 251 ms | 304 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
29 | Correct | 2 ms | 212 KB | Output is correct |
30 | Correct | 101 ms | 308 KB | Output is correct |
31 | Correct | 202 ms | 320 KB | Output is correct |
32 | Correct | 202 ms | 308 KB | Output is correct |
33 | Correct | 235 ms | 212 KB | Output is correct |
34 | Correct | 231 ms | 312 KB | Output is correct |
35 | Correct | 265 ms | 212 KB | Output is correct |
36 | Correct | 240 ms | 308 KB | Output is correct |
37 | Correct | 1 ms | 1236 KB | Output is correct |
38 | Incorrect | 3 ms | 2516 KB | Output isn't correct |
39 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 10 ms | 324 KB | Output is correct |
7 | Correct | 30 ms | 212 KB | Output is correct |
8 | Correct | 205 ms | 212 KB | Output is correct |
9 | Correct | 200 ms | 312 KB | Output is correct |
10 | Correct | 247 ms | 304 KB | Output is correct |
11 | Correct | 196 ms | 312 KB | Output is correct |
12 | Correct | 201 ms | 308 KB | Output is correct |
13 | Correct | 261 ms | 304 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 2 ms | 212 KB | Output is correct |
17 | Correct | 101 ms | 212 KB | Output is correct |
18 | Correct | 198 ms | 308 KB | Output is correct |
19 | Correct | 203 ms | 304 KB | Output is correct |
20 | Correct | 240 ms | 212 KB | Output is correct |
21 | Correct | 228 ms | 312 KB | Output is correct |
22 | Correct | 206 ms | 332 KB | Output is correct |
23 | Correct | 246 ms | 312 KB | Output is correct |
24 | Correct | 1 ms | 1236 KB | Output is correct |
25 | Incorrect | 2 ms | 2516 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |