結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-06 04:34:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 629 bytes |
コンパイル時間 | 1,339 ms |
コンパイル使用メモリ | 169,804 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 14:04:41 |
合計ジャッジ時間 | 3,225 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 18 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int64_t k, x, y; cin >> k >> x >> y; int64_t a[n]; int64_t sum = 0, maxi = 0; for(int i = 0; i < n; ++i) { cin >> a[i]; --a[i]; a[i] = (a[i] + k - 1) / k; sum += a[i]; maxi = max(maxi, a[i]); } sort(a, a + n); int64_t ans = maxi * y; int64_t cnt = 0; for(int64_t i = 0; i < n; ++i) { cnt = a[i]; sum -= a[i]; if(y < (n - i - 1) * x) continue; int64_t tmp = (sum - cnt * (n - i - 1)) * x + cnt * y; ans = min(ans, tmp); // cout << cnt << " " << sum << '\n'; // cout << tmp << '\n'; } cout << ans << '\n'; return 0; }