結果

問題 No.409 ダイエット
ユーザー vjudge1vjudge1
提出日時 2024-11-12 18:39:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 670 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 166,680 KB
実行使用メモリ 14,564 KB
最終ジャッジ日時 2024-11-12 18:40:07
合計ジャッジ時間 7,288 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55 TLE * 1 -- * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define il inline
#define ll long long
using namespace std;
il ll read(){
	ll a=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){a=a*10+ch-'0';ch=getchar();}
	return a*f;
}
ll n,A,B,f[300010],ruby[300010],ans=1e18;
int main(){
//	freopen("chips.in","r",stdin);
//	freopen("chips.out","w",stdout);
	memset(f,0x3f,sizeof f);
	n=read();A=read();B=read();f[0]=read();
	for(int i=1;i<=n;++i){
		ruby[i]=read();
		for(int j=i-1;j>=0;--j)
			f[i]=min(f[i],f[j]+ruby[i]-A*(i-j-1)+(i-j)*(i-j-1)*B/2);
	}
	for(int i=0;i<=n;++i)
		ans=min(ans,f[i]-A*(n-i)+(n-i+1)*(n-i)*B/2);
	cout<<ans;
	return 0;
}
0