이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long
using namespace std;
const int inf = (int)1e9 + 7 ;
const long long mod = 1e9 + 7;
const int N = (int)2007;
int n, arr[N], a, b, dp[N][N], ans = inf,pr[N];
main(){
memset(dp,0x3f3f3f3f,sizeof(dp));
dp[0][1] = 0;
cin >> n >> a >> b;
for(int i = 1;i <= n; i++){
cin >> arr[i];
pr[i] = pr[i - 1] + arr[i];
dp[i][1] = dp[i - 1][1] + arr[i];
}
for(int g = 2;g <= b; g++){
for(int i = 2;i <= n; i++){
for(int j = 2;j < i; j++){
dp[i][g] = min(dp[i][g], dp[j - 1][g - 1] | (pr[i] - pr[j - 1]));
}
}
}
for(int i = a;i <= b; i++){
//cout << dp[n][i] << " ";
ans = min(ans,dp[n][i]);
}
cout << ans;
}
/*
6 1 3
8 1 2 1 5 4
*/
컴파일 시 표준 에러 (stderr) 메시지
sculpture.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |