Submission #163990

# Submission time Handle Problem Language Result Execution time Memory
163990 2019-11-16T14:44:19 Z tuna Split the sequence (APIO14_sequence) C++11
0 / 100
2 ms 504 KB
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

const int N = 111;

int n, k, a[N], sum[N], con = 0;
vector <int> ans;

int get(int l, int r) {
	return sum[r] - sum[l - 1];
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	ans.push_back(n);
	while (k--) {
		int p = 1, mx = 0, res;
		for (int i = 0; i < (int)ans.size(); ++i) {
			for (int j = p; j < ans[i]; ++j) {
				int tmp = get(p, j) * get(j + 1, ans[i]);
				if (mx < tmp) {
					mx = tmp;
					res = j;
				}
			}
			p = ans[i] + 1;
		}
		con += mx;
		ans.push_back(res);
		sort(ans.begin(), ans.end());
	}
	cout << con << '\n';
	for (auto x : ans) {
		if (x == n) {
			break;
		}
		cout << x << ' ';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB contestant found the optimal answer: 108 == 108
2 Incorrect 2 ms 256 KB contestant didn't find the optimal answer: 951 < 999
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB contestant didn't find the optimal answer: 1093726 < 1093956
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -