結果

問題 No.1071 ベホマラー
ユーザー SeiyaYamaokaSeiyaYamaoka
提出日時 2020-06-05 22:48:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,185 bytes
コンパイル時間 1,165 ms
コンパイル使用メモリ 86,736 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-09 22:30:09
合計ジャッジ時間 4,919 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;

using ll = long long;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	ll k, x, y;
	cin >> n >> k >> x >> y;
	vector<ll> a(n);
	vector<ll> na(n,1);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll mp = 0;
	int sortcnt = 0;
	while (1) {
		int en = 0;
		for (int i = 0; i < a.size(); i++) {
			if (a[i] <= na[i]) {
				en++;
			}
		}
		if (en >= a.size()) { break; }

		int choi = 0;
		int ykk = 0;
		vector<ll> noa(n);
		for (int i = 0; i < na.size(); i++) {
			if (a[i] > na[i]) {
				ykk++;
				noa[i] = a[i] - na[i];
			}
		}

		if (y < ykk * x)choi = 1;

		if (choi == 1) {
			sort(noa.begin(), noa.end());
			if(noa[sortcnt] == 0)sortcnt++;
			ll kk = (noa[sortcnt] / k);
			if (kk == 0)kk++;
			for (int i = 0; i < na.size(); i++) {
				na[i] += k * kk;
			}mp += y * kk;
		}
		else if(choi == 0) {
			for (int i = 0; i < na.size(); i++) {
				if(a[i] > na[i]){
					ll kkk = (noa[i] / k);
					if (kkk == 0)kkk++;
					na[i] += k * kkk;
					mp += x * kkk;
					break;
				}
			}
		}
	}

	cout << mp << endl;

	return 0;
}
0