# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
185638 | 2020-01-12T02:38:17 Z | dndhk | Bali Sculptures (APIO15_sculpture) | C++14 | 3 ms | 376 KB |
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAX_N = 100; const int INF = 10000000; int N, A, B; vector<ll> v; ll dp[MAX_N+1][MAX_N+1]; ll ans; ll sum(ll x, ll y){ return dp[1][y] - dp[1][x-1]; } int main(){ scanf("%d%d%d", &N, &A, &B); v.pb(0LL); for(int i=1 ;i<=N; i++){ ll x; scanf("%lld", &x); v.pb(x); } for(int i=1; i<=N; i++){ dp[1][i] = dp[1][i-1] + v[i]; } for(int k=2; k<=N; k++){ for(int i=k; i<=N; i++){ dp[k][i] = (v[i] | dp[k-1][i-1]); for(int j=i-1; j>=k-1; j--){ dp[k][i] = min(dp[k][i], (sum(j, i) | dp[k-1][j-1])); } //cout<<k<<" "<<i<<" "<<dp[k][i]<<endl; } } ans = dp[A][N]; for(int i=A; i<=B; i++){ ans = min(ans, dp[i][N]); } cout<<ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |