結果

問題 No.31 悪のミックスジュース
ユーザー myantamyanta
提出日時 2017-05-04 09:53:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 40,812 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 07:34:05
合計ジャッジ時間 1,159 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,356 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,352 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0