結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-14 16:14:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 959 bytes |
| コンパイル時間 | 1,685 ms |
| コンパイル使用メモリ | 166,932 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 15:53:58 |
| 合計ジャッジ時間 | 2,409 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) (a)<=(n)&&(n)<(b)
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
const ll inf =1e18;
ll N,V;
int main(){
while(cin>>N>>V){
ll ans=0;
ll C[110] = {};
ll sum[110] = {};
ll dp[20210] = {};
REP(i,0,N){
cin>>C[i];
sum[i+1] = sum[i]+C[i];
}
ll x=1;
V-=N;
if(N>=V){
cout<<sum[N]<<endl;
continue;
}
REP(i,2,N+1){
if(x*sum[i]<i*sum[x]) x=i;
}
REP(i,0,min(20200LL,V)+1) {
dp[i]=inf;
if((V-i)%x==0) dp[i]=(V-i)/x*sum[x];
}
RREP(i,0,min(20000LL,V)+1) {
REP(j,1,N+1) dp[i]=min(dp[i],dp[i+j]+sum[j]);
}
cout<<dp[0]+sum[N]<<endl;
}
}
dnish