結果
問題 | No.1071 ベホマラー |
ユーザー |
![]() |
提出日時 | 2020-06-05 22:19:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 1,642 ms |
コンパイル使用メモリ | 172,368 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 16:00:57 |
合計ジャッジ時間 | 3,325 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)#define rep(i,n) REP(i,0,n)#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)#define ALLOF(c) (c).begin(), (c).end()typedef long long ll;typedef unsigned long long ull;int main(){ll N, K, X, Y;cin >> N >> K >> X >> Y;vector<ll> v;rep(i,N){ll a;cin >> a;ll x = (a-1+(K-1))/K;v.push_back(x);}sort(ALLOF(v));ll x = 0;rep(i,N+1){if(X*i<Y){x = i;}}ll y = -1;if(x == N){y = 0;}else{y = v[N-1-x];}ll ret = y * Y;rep(i,N){ll z = max(0LL, v[i]-y);ret += z * X;}cout << ret << endl;return 0;}