Submission #1192250

#TimeUsernameProblemLanguageResultExecution timeMemory
1192250ChuanChenBali Sculptures (APIO15_sculpture)C++20
0 / 100
0 ms400 KiB
#include<bits/stdc++.h> using namespace std; int n, A, B; int v[55], sv[55]; bool dp[55][55][505]; //dp[i][g][y] := using first i elements, making g groups, is it possible to have result equals y? //dp[i][g][y] is true if int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> A >> B; for(int i = 1; i <= n; i++){ cin >> v[i]; sv[i] = sv[i-1]+v[i]; } for(int i = 1; i <= n; i++){ dp[i][1][sv[i]] = true; } for(int i = 1; i <= n; i++){ for(int g = 1; g <= i; g++){ for(int y = 1; y <= n*10; y++){ //if dp[i][g][y] is true, dp[i+x][g+1][y|(sv[i+x]-sv[i-1])] is also true; if(!dp[i][g][y]) continue; for(int x = 1; i+x <= n; x++){ dp[i+x][g+1][y|(sv[i+x]-sv[i])] = true; } } } } for(int y = 1; y <= n*10; y++) for(int g = A; g <= B; g++) if(dp[n][g][y]){ cout << y << '\n'; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...