Submission #634647

#TimeUsernameProblemLanguageResultExecution timeMemory
634647tvladm2009Bali Sculptures (APIO15_sculpture)C++14
25 / 100
681 ms262144 KiB
#include <iostream> #include <algorithm> #include <vector> #define int long long using namespace std; const int MAX_N = 2 * 1e3; const int INF = (1LL << 60); const int MAX_L = 11; int y[MAX_N + 1], range[MAX_N + 1][MAX_N + 1]; vector<int> dp[MAX_N + 1][MAX_N + 1]; int n, a, b; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b; int mx = 0; for (int i = 1; i <= n; i++) { cin >> y[i]; mx = max(mx, n); range[i][i] = y[i]; } for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { range[i][j] = range[i][j - 1] + y[j]; } } for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j].push_back(INF); } } dp[0][0].push_back(0); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= i; k++) { for (int l = 0; l < min(100LL, (int)dp[k - 1][j - 1].size()); l++) { dp[i][j].push_back(dp[k - 1][j - 1][l] | range[k][i]); } } sort(dp[i][j].begin(), dp[i][j].end()); auto last = unique(dp[i][j].begin(), dp[i][j].end()); dp[i][j].erase(last, dp[i][j].end()); while (dp[i][j].size() > 100) { dp[i][j].pop_back(); } } } int answer = INF; for (int i = a; i <= b; i++) { for (int it : dp[n][i]) { answer = min(answer, it); } } cout << answer; return 0; } /* 20 1 3 9 9 8 8 10 8 8 8 8 9 9 8 8 8 9 8 10 8 9 8 */
#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...