답안 #312017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312017 2020-10-12T06:37:39 Z minhcool 수열 (APIO14_sequence) C++17
0 / 100
2000 ms 39776 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

const int N = 2e5 + 5, K = 205;

int n, k, a[N], suff[N];
ii dp[N][K];

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = n; i >= 1; i--) suff[i] = (suff[i + 1] + a[i]);
	for(int i = 1; i <= n; i++){
	    for(int j = 1; j <= min(i, k); j++){
	        for(int itr = i - 1; itr >= j; itr--) if(dp[i][j].fi < dp[itr][j - 1].fi + (suff[itr + 1] - suff[i + 1]) * suff[i + 1]) dp[i][j] = {dp[itr][j - 1].fi + (suff[itr + 1] - suff[i + 1]) * suff[i + 1], itr};
	    }
	}
    int ind = k;
    for(int i = k + 1; i <= n; i++){
        if(dp[i][k].fi > dp[ind][k].fi) ind = i;
    }
    cout << dp[ind][k].fi << "\n";
    vector<int> pos;
    pos.clear();
    int tmp = k;
    while(ind){
        pos.pb(ind);
        ind = dp[ind][tmp].se;
        tmp--;
    }
    for(int i = pos.size() - 1; i >= 0; i--) cout << pos[i] << " ";
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB declared answer doesn't correspond to the split scheme: declared = 62, real = 108
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB declared answer doesn't correspond to the split scheme: declared = 1063740, real = 754058
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1024 KB declared answer doesn't correspond to the split scheme: declared = 610500000, real = 510621050
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 3584 KB declared answer doesn't correspond to the split scheme: declared = 21458040, real = 14796084
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1424 ms 32536 KB declared answer doesn't correspond to the split scheme: declared = 1818458540, real = 1418738064
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2087 ms 39776 KB Time limit exceeded
2 Halted 0 ms 0 KB -