답안 #312019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312019 2020-10-12T06:39:41 Z minhcool 수열 (APIO14_sequence) C++17
0 / 100
2000 ms 41288 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 - 1); 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 Correct 1 ms 384 KB contestant found the optimal answer: 108 == 108
2 Correct 0 ms 384 KB contestant found the optimal answer: 999 == 999
3 Correct 1 ms 384 KB contestant found the optimal answer: 0 == 0
4 Correct 0 ms 384 KB contestant found the optimal answer: 1542524 == 1542524
5 Correct 1 ms 384 KB contestant found the optimal answer: 4500000000 == 4500000000
6 Incorrect 1 ms 384 KB declared answer doesn't correspond to the split scheme: declared = 1, real = 0
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB contestant found the optimal answer: 1093956 == 1093956
2 Correct 1 ms 512 KB contestant found the optimal answer: 302460000 == 302460000
3 Correct 1 ms 512 KB contestant found the optimal answer: 122453454361 == 122453454361
4 Correct 1 ms 512 KB contestant found the optimal answer: 93663683509 == 93663683509
5 Correct 1 ms 512 KB contestant found the optimal answer: 1005304678 == 1005304678
6 Correct 1 ms 512 KB contestant found the optimal answer: 933702 == 933702
7 Correct 1 ms 512 KB contestant found the optimal answer: 25082842857 == 25082842857
8 Incorrect 1 ms 512 KB declared answer doesn't correspond to the split scheme: declared = 687136, real = 678115
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1024 KB contestant found the optimal answer: 610590000 == 610590000
2 Correct 1 ms 1024 KB contestant found the optimal answer: 311760000 == 311760000
3 Correct 3 ms 1024 KB contestant found the optimal answer: 1989216017013 == 1989216017013
4 Correct 1 ms 1024 KB contestant found the optimal answer: 1499437552673 == 1499437552673
5 Correct 3 ms 1024 KB contestant found the optimal answer: 1019625819 == 1019625819
6 Correct 3 ms 1024 KB contestant found the optimal answer: 107630884 == 107630884
7 Correct 3 ms 1024 KB contestant found the optimal answer: 475357671774 == 475357671774
8 Incorrect 2 ms 1024 KB declared answer doesn't correspond to the split scheme: declared = 193556962, real = 193400941
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3584 KB contestant found the optimal answer: 21503404 == 21503404
2 Correct 7 ms 3584 KB contestant found the optimal answer: 140412195 == 140412195
3 Correct 169 ms 3588 KB contestant found the optimal answer: 49729674225461 == 49729674225461
4 Correct 6 ms 3584 KB contestant found the optimal answer: 37485571387523 == 37485571387523
5 Correct 165 ms 3576 KB contestant found the optimal answer: 679388326 == 679388326
6 Correct 139 ms 3576 KB contestant found the optimal answer: 4699030287 == 4699030287
7 Correct 172 ms 3576 KB contestant found the optimal answer: 12418819758185 == 12418819758185
8 Incorrect 154 ms 3576 KB declared answer doesn't correspond to the split scheme: declared = 31093317350, real = 31091859600
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1390 ms 32560 KB contestant found the optimal answer: 1818678304 == 1818678304
2 Correct 1389 ms 32656 KB contestant found the optimal answer: 1326260195 == 1326260195
3 Execution timed out 2095 ms 7416 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2075 ms 41288 KB Time limit exceeded
2 Halted 0 ms 0 KB -