結果
問題 | No.1071 ベホマラー |
ユーザー |
|
提出日時 | 2020-06-05 21:38:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 1,481 ms |
コンパイル使用メモリ | 174,460 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-12-17 13:45:41 |
合計ジャッジ時間 | 3,321 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 13 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } signed main(){ int n, k, x, y; cin >> n >> k >> x >> y; int a[100010]; for(int i = 0;i < n;i++){ cin >> a[i]; a[i]--; } int m = n; map<int, int> mp; int cnt = 0; for(int i = 0;i < n;i++){ int tmp = (a[i]+k-1)/k; mp[tmp]++; cnt += tmp; } int ans = cnt * x; int old = 0; int yy = 0; for(auto e : mp){ cnt -= m * (e.first-old); old = e.first; m -= e.second; chmin(ans, x*cnt + y*e.first); } cout << ans << endl; return 0; }