結果

問題 No.1071 ベホマラー
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2020-05-16 23:07:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,215 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 92,820 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 05:10:18
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,k,x,y;
  cin>>n>>k>>x>>y;
  assert(1<=n&&n<=100000);
  assert(1<=k&&k<=1000000000);
  assert(1<=x&&x<=1000000000);
  assert(1<=y&&y<=1000000000);
  vector<ll> v;
  v.pb(0);
  rep(i,0,n){
    ll a;
    cin>>a;
    assert(1<=a&&a<=1000000000);
    a--;
    v.pb((a+k-1)/k);
  }
  sort(all(v));
  ll ans = 0;
  rep(i,1,v.sz){
    ll d = v[i]-v[i-1];
    ans += d*min(x*(n+1-i),y);
  }
  cout << ans << endl;
  return 0;
}
0