結果

問題 No.1071 ベホマラー
ユーザー 👑 CleyL
提出日時 2022-01-14 00:30:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 20:26:34
合計ジャッジ時間 2,382 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 7 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,k,x,y;cin>>n>>k>>x>>y;
  vector<int> A(n+1);
  for(int i = 0; n > i; i++){
    cin>>A[i];A[i]--;
  }
  int z = min(n,y/x);
  //残りz人以下になった時はベホイミが最適
  sort(A.begin(),A.end(),greater<int>());

  long long ans = (A[z]+k-1)/k*y;
  for(int i = 0; z > i; i++){
    ans += x*(((A[i]-((A[z]+k-1)/k*k))+k-1)/k);
  }
  cout << ans << endl;
}
0