結果
問題 |
No.1071 ベホマラー
|
ユーザー |
|
提出日時 | 2020-06-07 00:55:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 79,140 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 14:32:29 |
合計ジャッジ時間 | 2,177 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <cassert> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main() { long long N, K, X, Y; cin >> N >> K >> X >> Y; vector<long long> A(N, 0); int Max = 0; rep(i, N) { cin >> A.at(i); A.at(i)--; if (A.at(i) > Max) { Max = A.at(i); } } long long ans = 0; int S = Y / X; long long ZERO = 0; if (S >= N) { rep(i, N) { ans += ((A.at(i) + K - 1) / K)*X; } } else if (S < 1) { ans= ((Max + K - 1) / K) * Y; } else { sort(A.begin(),A.end()); long long beho1 =( (A.at(N - S -1) + K - 1) / K); rep(i, N) { A.at(i) =std::max(A.at(i)-beho1 * K,ZERO); } rep(i, N) { ans += ((A.at(i) + K - 1) / K) * X; } ans += beho1 * Y; } cout << ans << endl; }