結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
myanta
|
| 提出日時 | 2017-05-04 09:53:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 589 bytes |
| コンパイル時間 | 666 ms |
| コンパイル使用メモリ | 38,656 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-14 06:44:42 |
| 合計ジャッジ時間 | 936 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d", &c[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
using namespace std;
using ll=long long;
int main(void)
{
int n, v, i, j, m;
vector<int> c;
ll s, s_add, s_min;
while(scanf("%d%d", &n, &v)==2)
{
c.clear();
c.resize(n, 0);
s=0;
for(i=0;i<n;i++)
{
scanf("%d", &c[i]);
s+=c[i];
}
if(v<=n)
{
printf("%lld\n", s);
continue;
}
v-=n;
s_min=s+(ll)c[0]*v;
for(i=1;i<=n;i++)
{
m=v-v/i*i;
s_add=0;
for(j=0;j<i;j++)
{
s_add+=(ll)c[j]*(v/i+(j<m));
}
if(s_min>s+s_add)
{
s_min=s+s_add;
}
}
printf("%lld\n", s_min);
}
return 0;
}
myanta