結果
問題 |
No.1071 ベホマラー
|
ユーザー |
|
提出日時 | 2020-06-05 21:30:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 475 bytes |
コンパイル時間 | 2,738 ms |
コンパイル使用メモリ | 196,864 KB |
最終ジャッジ日時 | 2025-01-10 22:10:19 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 13 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | lint k,x,y; scanf("%d%lld%lld%lld",&n,&k,&x,&y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | rep(i,n) scanf("%lld",&a[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n; lint k,x,y; scanf("%d%lld%lld%lld",&n,&k,&x,&y); vector<lint> a(n); rep(i,n) scanf("%lld",&a[i]); rep(i,n) a[i]=(a[i]-1+k-1)/k; sort(a.begin(),a.end()); vector<lint> cum(n+1); rep(i,n) cum[i+1]=cum[i]+a[i]; lint ans=cum[n]*x; rep(i,n){ ans=min(ans,a[i]*y+(cum[n]-cum[i+1]-(n-i-1)*a[i])*x); } printf("%lld\n",ans); return 0; }