結果

問題 No.1071 ベホマラー
ユーザー MiMi
提出日時 2020-06-06 15:47:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,328 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 205,728 KB
実行使用メモリ 7,064 KB
最終ジャッジ日時 2023-08-25 01:10:44
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 20 ms
5,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 26 ms
6,936 KB
testcase_18 AC 25 ms
7,064 KB
testcase_19 AC 26 ms
6,932 KB
testcase_20 AC 19 ms
7,044 KB
testcase_21 WA -
testcase_22 AC 21 ms
7,056 KB
testcase_23 AC 19 ms
7,056 KB
testcase_24 AC 25 ms
7,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/istream:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/sstream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/complex:45,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ccomplex:39,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:54,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]’ 内,
    inlined from ‘int main()’ at main.cpp:55:11:
/usr/local/gcc7/include/c++/12.2.0/ostream:202:25: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:44:8: 備考: ‘ans’ はここで定義されています
   44 |     ll ans;
      |        ^~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    vector<ll> a(n);
    vector<__int128_t> cnt(n),sum(n+1,0);
    rep(i,n){
        cin>>a[i];
        a[i]--;
        cnt[i]=(a[i]+k-1)/k;
    }
    sort(begin(cnt),end(cnt));
    rep(i,n){
        sum[i+1]=sum[i]+cnt[i];
    }
    ll ans;
    rep(i,n+1){//i-1まで全体魔法で消す
        __int128_t now;
        if(i){
            now=cnt[i-1]*y+(sum[n]-sum[i]-cnt[i-1]*(n-i))*x;
            if(now<(1ll<<61)) chmin(ans,ll(now));
        }else{
            now=sum[n]*x;
            if(now<(1ll<<61)) ans=now;
        }
    }
    cout<<ans<<endl;
}
0