結果
問題 |
No.1071 ベホマラー
|
ユーザー |
|
提出日時 | 2021-03-23 08:00:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 727 bytes |
コンパイル時間 | 838 ms |
コンパイル使用メモリ | 95,916 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-24 23:34:18 |
合計ジャッジ時間 | 3,115 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#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; }