# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163373 | 2019-11-12T23:46:17 Z | combi1k1 | Bali Sculptures (APIO15_sculpture) | C++14 | 4 ms | 632 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 2e3 + 1; ll a[N]; ll f[N][N]; int g[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int A; cin >> A; int B; cin >> B; for(int i = 1 ; i <= n ; ++i) { cin >> a[i]; a[i] += a[i - 1]; } assert(A > 1); if (A > 1) { for(int i = 1 ; i <= n ; ++i) f[i][0] = 1e18; for(int i = 1 ; i <= n ; ++i) for(int j = 1 ; j <= i ; ++j) { f[i][j] = 1e18; for(int k = j - 1 ; k < i ; ++k) f[i][j] = min(f[i][j],f[k][j - 1] | (a[i] - a[k])); } ll ans = 1e18; for(int i = A ; i <= B ; ++i) ans = min(ans,f[n][i]); cout << ans; } else { ll cur_mask = 0; for(int b = 40 ; b >= 0 ; --b) { for(int i = 1 ; i <= n ; ++i) { g[i] = 1e9; int t = 0; for(int j = 0 ; j < i ; ++j) { ll S = a[i] - a[j]; S >>= b; S <<= b; if ((S & cur_mask) != S) continue; g[i] = min(g[i],g[j] + 1); } } if (g[n] > B) cur_mask |= (1ll << b); } cout << cur_mask << endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 632 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |