結果

問題 No.1071 ベホマラー
ユーザー seratnaseratna
提出日時 2020-06-19 03:55:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 883 bytes
コンパイル時間 962 ms
コンパイル使用メモリ 104,560 KB
実行使用メモリ 8,176 KB
最終ジャッジ日時 2023-09-16 12:35:08
合計ジャッジ時間 5,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    if(a[n-1] == 1){
        cout<<0<<endl;
        return 0;
    }

    ll ans = 0;
    ll tmp = 0;
    for(ll i=0;i<n;i++){
        if(a[i] == 1){
            tmp++;
        }
    }
    for(ll i=0;i<(a[n-1]-1+k-1)/k;i++){
        ans += min( (n-tmp)*x, y);
        while(i == (a[tmp]-1+k-1)/k-1){
            tmp++;
        }
        // cout<<ans<<" "<<n-tmp<<endl;
    }

    cout<<ans<<endl;
}
0