結果
問題 | No.1071 ベホマラー |
ユーザー |
|
提出日時 | 2020-06-05 21:53:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 1,571 ms |
コンパイル使用メモリ | 172,552 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 14:25:53 |
合計ジャッジ時間 | 3,000 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for (int i = 0; i < (n); i ++)using namespace std;using ll = long long;using PL = pair<ll,ll>;using P = pair<int,int>;constexpr int INF = 1000000000;constexpr long long HINF = 1000000000000000;constexpr long long MOD = 1000000007;constexpr double EPS = 1e-4;constexpr double PI = 3.14159265358979;int main() {ll N,K,X,Y; cin >> N >> K >> X >> Y;vector<ll> A(N);rep(i,N) {cin >> A[i];A[i] --;}sort(A.begin(),A.end());int people = Y/X;ll ans = 0;if (people == 0) {ans = (A[N - 1] + K - 1)/K * Y;cout << ans << endl;return 0;}if (people >= N) {rep(i,N) ans += (A[i] + K - 1)/K * X;cout << ans << endl;return 0;}ll damage = (A[N - people - 1] + K - 1)/K * K;ans = (A[N - people - 1] + K - 1)/K * Y;for (int i = N - people;i < N;i ++) {if (A[i] - damage > 0) {ans += (A[i] - damage + K - 1)/K * X;}}cout << ans << endl;return 0;}