結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-05 21:49:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 851 bytes |
コンパイル時間 | 1,527 ms |
コンパイル使用メモリ | 163,240 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-17 14:16:33 |
合計ジャッジ時間 | 3,181 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 5 WA * 15 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.05 21:46:51 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { ll n, k, x, y; cin >> n >> k >> x >> y; vector< ll > a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll p = (y + x - 1) / x; ll ans = 0; sort(a.begin(), a.end()); if (p <= 1) { cout << (a[n - 1] - 1 + k - 1) / k * y << endl; return 0; } if (p > n) { for (int i = 0; i < n; i++) { ans += (a[i] - 1 + k - 1) / k * x; } cout << ans << endl; return 0; } ll q = (a[n - p] - 1 + k - 1) / k; ans = (a[n - p] - 1 + k - 1) / k * y; for (int i = p; i < n; i++) { ans += (a[i] - 1 - q * k + k - 1) / k * x; } cout << ans << endl; return 0; }