Submission #3213489


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n;
ll x, ans = (ll)9e18, a[200005];

int main() {
	cin >> n >> x;
	for(int i = 1; i <= n; ++i) cin >> a[i], a[i] += a[i-1];
	for(int k = 1; k <= n; ++k) {
		ll coef = 3LL, sum = 0;
		for(int i = n; i >= 1; i -= k) sum += (a[i]-a[max(0, i-k)])*max(coef, 5LL), coef += 2;
		ans = min(ans, sum+(k+n)*x);
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task B - Garbage Collector
User dummyummy
Language C++14 (GCC 5.4.1)
Score 400
Code Size 431 Byte
Status
Exec Time 85 ms
Memory 1792 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 400 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt
All 0 / 300 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB
stest_01.txt 2 ms 256 KB
stest_02.txt 2 ms 256 KB
stest_03.txt 1 ms 256 KB
stest_04.txt 1 ms 256 KB
stest_05.txt 1 ms 256 KB
stest_06.txt 1 ms 256 KB
stest_07.txt 2 ms 256 KB
stest_08.txt 2 ms 256 KB
stest_09.txt 1 ms 256 KB
stest_10.txt 2 ms 256 KB
stest_11.txt 2 ms 256 KB
stest_12.txt 1 ms 256 KB
test_13.txt 85 ms 1792 KB
test_14.txt 85 ms 1792 KB
test_15.txt 18 ms 512 KB
test_16.txt 65 ms 1792 KB
test_17.txt 64 ms 1792 KB
test_18.txt 10 ms 512 KB
test_19.txt 77 ms 1792 KB
test_20.txt 73 ms 1792 KB
test_21.txt 73 ms 1792 KB
test_22.txt 73 ms 1792 KB
test_23.txt 65 ms 1792 KB
test_24.txt 65 ms 1792 KB
test_25.txt 32 ms 1024 KB
test_26.txt 73 ms 1792 KB
test_27.txt 73 ms 1792 KB
test_28.txt 59 ms 1536 KB