結果

問題 No.1071 ベホマラー
ユーザー betit0919betit0919
提出日時 2020-06-05 21:33:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,428 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 130,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 14:29:37
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 19 ms
4,380 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 21 ms
4,380 KB
testcase_15 AC 23 ms
4,376 KB
testcase_16 AC 23 ms
4,380 KB
testcase_17 AC 23 ms
4,376 KB
testcase_18 AC 23 ms
4,380 KB
testcase_19 AC 23 ms
4,376 KB
testcase_20 AC 17 ms
4,376 KB
testcase_21 AC 17 ms
4,380 KB
testcase_22 AC 17 ms
4,380 KB
testcase_23 AC 17 ms
4,380 KB
testcase_24 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,K,X,Y;
  cin>>N>>K>>X>>Y;
  vector<ll>A(N);
  REP(i,N){
    cin>>A[i];
    A[i]--;
    A[i]=(A[i]+K-1)/K;
  }
  //途中まで全部ベホマラー ベホマラー1回によりベホイミ○回のほうが効率的
  sort(rALL(A));
  if(Y<=X){
    cout<<A[0]*Y<<endl;
  }else{
    ll a=(Y)/X-1;
    //上からa人はベホイミで削る
    if(a>N-1){
      //すべてベホイミ
      cout<<accumulate(ALL(A),0ll)*X<<endl;
    }else{
      ll ans=A[a+1]*Y;
      REP(i,a+1){
        ans+=(A[i]-A[a+1])*X;
      }
      cout<<ans<<endl;
    }
  }
}
0