이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#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 Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
#define pi pair < long long, long long >
using namespace std;
const long long INF = (int)1e18 + 7;
const int N = (int)1007;
const int mod = 1000000007;
int n, k, arr[N], pr[N];
int dp[N][201];
main(){
cin >> n >> k;
for(int i = 1;i <= n; i++){
cin >> arr[i];
pr[i] = pr[i - 1] + arr[i];
}
for(int i = 1;i <= n; i++){
for(int j = 1;j <= k; j++){
for(int l = 1;l <= i; l++){
dp[i][j] = max(dp[i][j],(dp[l][j - 1] + (((pr[n] - pr[i])) * (pr[i] - pr[l]))));
}
}
}
cout << dp[n][k];
}
/*
7 3
4 1 3 4 0 2 3
*/
컴파일 시 표준 에러 (stderr) 메시지
sequence.cpp:21: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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |