結果

問題 No.1071 ベホマラー
コンテスト
ユーザー 夜
提出日時 2021-03-23 08:00:02
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 39 ms / 2,000 ms
+ 611µs
コード長 727 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 516 ms
コンパイル使用メモリ 111,892 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-09-29 13:06:23
合計ジャッジ時間 3,411 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[100010], m[100010], z = 0;
int main() {
	long long n, k, x, y;
	cin >> n >> k >> x >> y;
	long long l = y / x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		m[i] = (a[i] + k - 1) / k;
	}
	sort(a, a + n);
	sort(m, m + n);
	long long ans = 0, r = 0;
	if (n - l - 1 >= 0) {
		ans += m[n - l - 1] * y;
		r = m[n - l - 1];
	}
	for (int i = max(z, n - l); i < n; i++) {
		ans += (m[i] - r) * x;
	}
	cout << ans << endl;
}
0