Submission #3211070


Source Code Expand

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

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

int main(){
	long long N,X;cin>>N>>X;
	ll n=N,x=X;
	rep(i,n){
		long long A;scanf("%lld",&A);
		sum[i]=a[i]=A;
	}
	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((ll)0,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<<(long long)ans<<endl;
}

Submission Info

Submission Time
Task B - Garbage Collector
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 700
Code Size 629 Byte
Status
Exec Time 47 ms
Memory 8576 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   long long A;scanf("%lld",&A);
                               ^

Judge Result

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 300 / 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 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 2 ms 2304 KB
stest_02.txt 2 ms 2304 KB
stest_03.txt 1 ms 2304 KB
stest_04.txt 1 ms 2304 KB
stest_05.txt 2 ms 2304 KB
stest_06.txt 1 ms 2304 KB
stest_07.txt 2 ms 2304 KB
stest_08.txt 2 ms 2304 KB
stest_09.txt 1 ms 2304 KB
stest_10.txt 2 ms 2304 KB
stest_11.txt 2 ms 2304 KB
stest_12.txt 1 ms 2304 KB
test_13.txt 47 ms 8448 KB
test_14.txt 47 ms 8448 KB
test_15.txt 10 ms 2944 KB
test_16.txt 44 ms 8448 KB
test_17.txt 44 ms 8448 KB
test_18.txt 7 ms 2816 KB
test_19.txt 45 ms 8448 KB
test_20.txt 45 ms 8448 KB
test_21.txt 45 ms 8448 KB
test_22.txt 45 ms 8448 KB
test_23.txt 44 ms 8576 KB
test_24.txt 44 ms 8448 KB
test_25.txt 22 ms 5888 KB
test_26.txt 46 ms 8448 KB
test_27.txt 45 ms 8448 KB
test_28.txt 37 ms 8448 KB