| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 32118 | gs14004 | 수열 (APIO14_sequence) | C++14 | 2000 ms | 4360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> pi;
int n,k;
lint dp[100005], a[100005];
int trk[100005], cnt[100005];
pi trial(lint x){
for(int i=1; i<=n; i++){
dp[i] = -1e18;
for(int j=0; j<i; j++){
if(dp[i] <= dp[j] + 2 * (a[n] - a[i]) * (a[i] - a[j]) - x){
dp[i] = dp[j] + 2 * (a[i] - a[j]) * (a[n] - a[i]) - x;
trk[i] = j;
cnt[i] = cnt[j] + 1;
}
}
}
return pi(dp[n], cnt[n]);
}
int main(){
int t;
scanf("%d %d",&n,&k);
for (int i=0; i<n; i++) {
scanf("%d",&t);
a[i+1] = a[i] + t;
}
lint s = -1, e = 1e13;
while(s != e){
lint m = s + (e - s + 1)/2;
if(trial(m).second >= k+1) s = m;
else e = m-1;
}
cout << (trial(s).first + s * (k+1)) / 2 << endl;
int p = n;
vector<int> v;
for(int j=k; j; j--){
v.push_back(trk[p]);
p = trk[p];
}
reverse(v.begin(), v.end());
for(auto &i : v) printf("%d ", i);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
