Submission #3205157


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll a[300000];
ll dp[3000][3000];

signed main(){
	ll n,x;scanf("%lld%lld",&n,&x);
	if(n>3000)abort();
	rep(i,n)scanf("%lld",&a[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[n-1][1]=x+a[n-1];
	for(int i=n-1;i>0;i--)for(int j=0;j<=n;j++){
		if(dp[i][j]==INFL)continue;
		//つなぐ
		dp[i-1][j+1]=min(dp[i-1][j+1],dp[i][j]+(a[i]-a[i-1])*(j+1)*(j+1));
		//切る
		dp[i-1][1]=min(dp[i-1][1],dp[i][j]+a[i]*(j+1)*(j+1)+a[i-1]+x);
	}
	ll Min=INFL;
	rep(i,n+1)Min=min(Min,dp[0][i]+(i+1)*(i+1)*a[0]);
	cout<<Min+x*n<<endl;
}

Submission Info

Submission Time
Task B - Garbage Collector
User autumn_eel
Language C++14 (GCC 5.4.1)
Score 0
Code Size 768 Byte
Status
Exec Time 97 ms
Memory 72064 KB

Compile Error

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

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 400 0 / 300
Status
× 4
× 11
× 5
× 11
× 5
× 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 23 ms 71936 KB
sample_02.txt 23 ms 71936 KB
sample_03.txt 23 ms 71936 KB
sample_04.txt 23 ms 71936 KB
stest_01.txt 31 ms 71936 KB
stest_02.txt 32 ms 71936 KB
stest_03.txt 23 ms 71936 KB
stest_04.txt 23 ms 71936 KB
stest_05.txt 29 ms 72064 KB
stest_06.txt 27 ms 71936 KB
stest_07.txt 32 ms 71936 KB
stest_08.txt 31 ms 71936 KB
stest_09.txt 24 ms 71936 KB
stest_10.txt 31 ms 71936 KB
stest_11.txt 31 ms 71936 KB
stest_12.txt 23 ms 71936 KB
test_13.txt 96 ms 256 KB
test_14.txt 97 ms 256 KB
test_15.txt 96 ms 256 KB
test_16.txt 97 ms 256 KB
test_17.txt 97 ms 256 KB
test_18.txt 97 ms 256 KB
test_19.txt 97 ms 256 KB
test_20.txt 96 ms 256 KB
test_21.txt 97 ms 256 KB
test_22.txt 96 ms 256 KB
test_23.txt 96 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 96 ms 256 KB
test_28.txt 96 ms 256 KB