結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-10-19 07:15:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,433 bytes |
| コンパイル時間 | 742 ms |
| コンパイル使用メモリ | 71,016 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-30 09:41:40 |
| 合計ジャッジ時間 | 1,496 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <fstream>
#include <sstream>
using namespace std;
typedef long long ll;
const ll INF = 1ll << 60;
const int dp_size = 20000;
int N, V;
int C[110];
ll S[110];
ll dp[dp_size];
int main(){
cin >> N >> V;
for(int i=0;i<N;i++)cin >> C[i];
S[0] = 0;
for(int i=0;i<N;i++)S[i+1] = S[i] + C[i];
for(int i=0;i<dp_size;i++){
dp[i] = INF;
}
dp[0] = 0;
for(int sum=0;sum<dp_size;sum++){
for(int i=1;i<=N;i++){
if(i <= sum)dp[sum] = min(dp[sum], dp[sum - i] + S[i]);
}
}
int opt = 1;
for(int i=2;i<=N;i++){
if(S[i] * opt < S[opt] * i){
opt = i;
}
}
/*ll res = INF;
for(int i=0;i<dp_size;i++){
ll tmp = 0;
int v = V;
v -= N;
tmp += S[N];
v -= i;
tmp += dp[i];
if(v <= 0){
res = min(res, tmp);
continue;
}
tmp += (v + opt - 1) / opt * S[opt];
res = min(res, tmp);
}*/
ll res = S[N];
V -= N;
if(V > 0){
res += V / opt * S[opt];
res += dp[V % opt];
}
cout << res << endl;
return 0;
}