結果
問題 |
No.1071 ベホマラー
|
ユーザー |
![]() |
提出日時 | 2020-06-06 04:04:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 2,022 ms |
コンパイル使用メモリ | 170,016 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 12:47:37 |
合計ジャッジ時間 | 3,226 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 13 WA * 7 |
ソースコード
#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; for(int i = 0; i < n; ++i) { cin >> a[i]; --a[i]; a[i] = (a[i] + k - 1) / k; sum += a[i]; } sort(a, a + n); int64_t ans = sum * x; int64_t cnt = 0; for(int i = 0; i < n; ++i) { cnt = a[i]; sum -= a[i]; // cout << cnt << " " << sum << '\n'; int64_t tmp = (sum - cnt * (n - i - 1)) * x + cnt * y; // cout << tmp << '\n'; ans = min(ans, tmp); } cout << ans << '\n'; return 0; }