結果

問題 No.1071 ベホマラー
ユーザー KKT89
提出日時 2020-06-27 10:59:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 88,728 KB
最終ジャッジ日時 2025-01-11 12:41:08
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k,x,y; cin >> n >> k >> x >> y;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
        a[i]=(a[i]+k-1)/k;
    }
    ll res=0;
    sort(a.begin(), a.end());
    ll cnt=0;
    for(int i=0;i<n;i++){
        if((n-i)*x>y){
            res+=(a[i]-cnt)*y;
            cnt=a[i];
        }
        else{
            res+=(a[i]-cnt)*x;
        }
    }
    cout << res << endl;
}
0