Submission #3211048


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll a[300000];
ll sum[300000];

int main(){
	ll n,x;cin>>n>>x;
	if(n>2000)abort();
	rep(i,n)scanf("%lld",&a[i]),sum[i]=a[i];
	for(int i=1;i<n;i++)sum[i]+=sum[i-1];
	ll ans=LLONG_MAX;
	for(ll k=1;k<=n;k++){//何回往復するか?
		ll cnt=(n+k)*x;
		for(ll c=0;c<(n+k-1)/k;c++){
			ll l=max(0LL,n-1-(c+1)*k+1),r=n-1-c*k;
			if(c==0)cnt+=(sum[r]-(l==0?0:sum[l-1]))*5;
			else cnt+=(2*c+3)*(sum[r]-(l==0?0:sum[l-1]));
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task B - Garbage Collector
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 400
Code Size 593 Byte
Status
Exec Time 98 ms
Memory 2304 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,n)scanf("%lld",&a[i]),sum[i]=a[i];
                                         ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 400 / 400 0 / 300
Status
× 4
× 16
× 16
× 16
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 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 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 2 ms 2304 KB
sample_02.txt 1 ms 2304 KB
sample_03.txt 1 ms 2304 KB
sample_04.txt 1 ms 2304 KB
stest_01.txt 1 ms 2304 KB
stest_02.txt 2 ms 2304 KB
stest_03.txt 1 ms 2304 KB
stest_04.txt 2 ms 2304 KB
stest_05.txt 2 ms 2304 KB
stest_06.txt 2 ms 2304 KB
stest_07.txt 2 ms 2304 KB
stest_08.txt 1 ms 2304 KB
stest_09.txt 1 ms 2304 KB
stest_10.txt 2 ms 2304 KB
stest_11.txt 1 ms 2304 KB
stest_12.txt 1 ms 2304 KB
test_13.txt 97 ms 256 KB
test_14.txt 96 ms 256 KB
test_15.txt 96 ms 256 KB
test_16.txt 98 ms 256 KB
test_17.txt 97 ms 256 KB
test_18.txt 96 ms 256 KB
test_19.txt 96 ms 256 KB
test_20.txt 96 ms 256 KB
test_21.txt 96 ms 256 KB
test_22.txt 96 ms 256 KB
test_23.txt 97 ms 256 KB
test_24.txt 96 ms 256 KB
test_25.txt 96 ms 256 KB
test_26.txt 96 ms 256 KB
test_27.txt 97 ms 256 KB
test_28.txt 96 ms 256 KB