# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
597249 | 2022-07-15T19:36:31 Z | Belphegor | Bali Sculptures (APIO15_sculpture) | C++14 | 251 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<=1000; 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<=1000; 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 | 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 212 KB | Output is correct |
7 | Correct | 24 ms | 328 KB | Output is correct |
8 | Correct | 197 ms | 308 KB | Output is correct |
9 | Correct | 202 ms | 312 KB | Output is correct |
10 | Correct | 202 ms | 312 KB | Output is correct |
11 | Correct | 212 ms | 304 KB | Output is correct |
12 | Correct | 202 ms | 312 KB | Output is correct |
13 | Correct | 236 ms | 308 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 | 25 ms | 328 KB | Output is correct |
21 | Correct | 206 ms | 308 KB | Output is correct |
22 | Correct | 197 ms | 212 KB | Output is correct |
23 | Correct | 215 ms | 304 KB | Output is correct |
24 | Correct | 205 ms | 312 KB | Output is correct |
25 | Correct | 213 ms | 304 KB | Output is correct |
26 | Correct | 248 ms | 304 KB | Output is correct |
27 | Correct | 0 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 | 100 ms | 212 KB | Output is correct |
31 | Correct | 205 ms | 308 KB | Output is correct |
32 | Correct | 210 ms | 308 KB | Output is correct |
33 | Correct | 228 ms | 308 KB | Output is correct |
34 | Correct | 230 ms | 308 KB | Output is correct |
35 | Correct | 211 ms | 308 KB | Output is correct |
36 | Correct | 241 ms | 212 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 | 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 | 27 ms | 328 KB | Output is correct |
8 | Correct | 211 ms | 304 KB | Output is correct |
9 | Correct | 199 ms | 308 KB | Output is correct |
10 | Correct | 213 ms | 212 KB | Output is correct |
11 | Correct | 221 ms | 304 KB | Output is correct |
12 | Correct | 197 ms | 308 KB | Output is correct |
13 | Correct | 229 ms | 212 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 | 8 ms | 212 KB | Output is correct |
20 | Correct | 25 ms | 324 KB | Output is correct |
21 | Correct | 206 ms | 308 KB | Output is correct |
22 | Correct | 204 ms | 308 KB | Output is correct |
23 | Correct | 211 ms | 308 KB | Output is correct |
24 | Correct | 197 ms | 312 KB | Output is correct |
25 | Correct | 199 ms | 212 KB | Output is correct |
26 | Correct | 251 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 | 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 | 7 ms | 212 KB | Output is correct |
7 | Correct | 29 ms | 212 KB | Output is correct |
8 | Correct | 220 ms | 308 KB | Output is correct |
9 | Correct | 196 ms | 312 KB | Output is correct |
10 | Correct | 220 ms | 308 KB | Output is correct |
11 | Correct | 223 ms | 304 KB | Output is correct |
12 | Correct | 200 ms | 304 KB | Output is correct |
13 | Correct | 234 ms | 312 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 | 0 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 | 332 KB | Output is correct |
7 | Correct | 25 ms | 320 KB | Output is correct |
8 | Correct | 208 ms | 212 KB | Output is correct |
9 | Correct | 197 ms | 212 KB | Output is correct |
10 | Correct | 227 ms | 304 KB | Output is correct |
11 | Correct | 198 ms | 212 KB | Output is correct |
12 | Correct | 204 ms | 304 KB | Output is correct |
13 | Correct | 251 ms | 304 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 | 0 ms | 212 KB | Output is correct |
19 | Correct | 7 ms | 328 KB | Output is correct |
20 | Correct | 24 ms | 332 KB | Output is correct |
21 | Correct | 230 ms | 212 KB | Output is correct |
22 | Correct | 212 ms | 308 KB | Output is correct |
23 | Correct | 200 ms | 304 KB | Output is correct |
24 | Correct | 201 ms | 312 KB | Output is correct |
25 | Correct | 209 ms | 308 KB | Output is correct |
26 | Correct | 226 ms | 304 KB | Output is correct |
27 | Correct | 0 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 | 212 KB | Output is correct |
31 | Correct | 208 ms | 316 KB | Output is correct |
32 | Correct | 211 ms | 308 KB | Output is correct |
33 | Correct | 225 ms | 308 KB | Output is correct |
34 | Correct | 245 ms | 304 KB | Output is correct |
35 | Correct | 208 ms | 304 KB | Output is correct |
36 | Correct | 228 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 | 7 ms | 212 KB | Output is correct |
7 | Correct | 24 ms | 212 KB | Output is correct |
8 | Correct | 197 ms | 304 KB | Output is correct |
9 | Correct | 195 ms | 308 KB | Output is correct |
10 | Correct | 204 ms | 316 KB | Output is correct |
11 | Correct | 209 ms | 304 KB | Output is correct |
12 | Correct | 198 ms | 304 KB | Output is correct |
13 | Correct | 237 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 | 103 ms | 212 KB | Output is correct |
18 | Correct | 202 ms | 304 KB | Output is correct |
19 | Correct | 203 ms | 312 KB | Output is correct |
20 | Correct | 233 ms | 308 KB | Output is correct |
21 | Correct | 234 ms | 212 KB | Output is correct |
22 | Correct | 208 ms | 212 KB | Output is correct |
23 | Correct | 245 ms | 308 KB | Output is correct |
24 | Correct | 1 ms | 1236 KB | Output is correct |
25 | Incorrect | 4 ms | 2516 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |