結果

問題 No.1071 ベホマラー
ユーザー CleverLarry0702CleverLarry0702
提出日時 2022-12-01 12:10:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 166,732 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 03:01:18
合計ジャッジ時間 3,801 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N=1e5+100;
ll n,m,x,y;
ll a[N];
ll ans;

int main()
{
    cin>>n>>m>>x>>y;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]--;
        if(a[i]%m==0) a[i]/=m;
        else a[i]=a[i]/m+1;
    }
    sort(a+1,a+1+n);
    int left=n,now=0;
    for(int i=1;i<=n;i++)
    {
        a[i]-=now;
        if(!a[i]) { left--;continue; }
        if((ll)left*x>y)
        {
            left--;
            now+=a[i];
            ans+=y*a[i];
        }
        else
        {
            left--;
            ans+=x*a[i];
        }
    }
    cout<<ans;
    return 0;
}
0