結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
kriii
|
| 提出日時 | 2014-12-15 00:59:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 635 bytes |
| コンパイル時間 | 193 ms |
| コンパイル使用メモリ | 23,424 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-06-11 21:10:40 |
| 合計ジャッジ時間 | 997 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf ("%d %lld",&N,&V);
| ~~~~~~^~~~~~~~~~~~~~~~~
main.cpp:8:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | for (int i=1;i<=N;i++) scanf ("%lld",&C[i]), C[i] += C[i-1];
| ~~~~~~^~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int N; long long V,C[101],D[1001];
int main()
{
scanf ("%d %lld",&N,&V);
for (int i=1;i<=N;i++) scanf ("%lld",&C[i]), C[i] += C[i-1];
int x = 1;
for (int i=2;i<=N;i++) if (C[x] * i > C[i] * x) x = i;
for (int i=1;i<=1000;i++){
D[i] = 1e18;
for (int j=1;j<=N;j++) if (i >= j){
if (D[i] > D[i-j] + C[j])
D[i] = D[i-j] + C[j];
}
}
long long ans = 1e18;
V -= N;
if (V < 0) ans = C[N];
for (int i=0;i<=1000;i++) if (i <= V){
int r = (V - i + x - 1) / x;
long long w = C[N] + D[i] + C[x] * r;
if (ans > w)
ans = w;
}
printf ("%lld\n",ans);
return 0;
}
kriii