結果

問題 No.1071 ベホマラー
コンテスト
ユーザー Rayhan Ahmad
提出日時 2020-06-06 00:04:35
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 451 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,479 ms
コンパイル使用メモリ 176,924 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-24 09:18:17
合計ジャッジ時間 3,051 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:10: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
    9 |     ll a[n];
      |          ^
main.cpp:9:10: note: read of non-const variable 'n' is not allowed in a constant expression
main.cpp:7:8: note: declared here
    7 |     ll n,k,x,y;
      |        ^
1 warning generated.

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
#define Ll __int128
#define ll unsigned long long
int main()
{
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    ll a[n];
    vector<ll> v;
    for(int i=0; i<n; i++){
        cin>>a[i];
        v.push_back((a[i]-1+k-1)/k);
    }
    sort(v.begin(),v.end());
    ll ans=0;
    ll now=0;
    for(int i=0; i<n; i++){
        ll u=v[i];
        ans+=min(y,(n-i)*x)*(u-now);
        now=u;
    }
    cout<<ans<<endl;
}
0