結果

問題 No.31 悪のミックスジュース
ユーザー startcppstartcpp
提出日時 2018-02-08 21:22:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 57,848 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-25 07:38:03
合計ジャッジ時間 1,648 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, v;
int c[100];

signed main() {
	int i, num;
	int sumC = 0;
		
	cin >> n >> v;
	for (i = 0; i < n; i++) cin >> c[i];
	for (i = 0; i < n; i++) sumC += c[i];
	v -= n;
	if (v <= 0) { cout << sumC << endl; return 0; }
	
	int ans = 1e+15;
	for (num = 1; num <= n; num++) {
		int syo = v / num;
		int mod = v % num;
		int cst = 0;
		
		for (i = 0; i < mod; i++) {
			cst += (syo + 1) * c[i];
		}
		for (i = mod; i < num; i++) {
			cst += syo * c[i];
		}
		ans = min(ans, cst);
	}
	ans += sumC;
	
	cout << ans << endl;
	return 0;
}
0