結果
| 問題 | No.1071 ベホマラー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 21:51:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,065 bytes |
| 記録 | |
| コンパイル時間 | 1,695 ms |
| コンパイル使用メモリ | 173,148 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 14:22:44 |
| 合計ジャッジ時間 | 3,265 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 1 |
| other | AC * 18 WA * 2 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In member function '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:31:17:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
202 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:23:8: note: 'ans' was declared here
23 | ll ans;
| ^~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
int main() {
ll N,K,X,Y; cin >> N >> K >> X >> Y;
vector<ll> A(N);
rep(i,N) {
cin >> A[i];
A[i] --;
}
sort(A.begin(),A.end());
int people = Y/X;
ll ans;
if (people == 0) {
ans = (A[N - 1] + K - 1)/K * Y;
cout << ans << endl;
return 0;
}
if (people >= N) {
rep(i,N) ans += (A[i] + K - 1)/K * X;
cout << ans << endl;
return 0;
}
ll damage = (A[N - people - 1] + K - 1)/K * K;
ans = (A[N - people - 1] + K - 1)/K * Y;
for (int i = N - people;i < N;i ++) {
if (A[i] - damage > 0) {
ans += (A[i] - damage + K - 1)/K * X;
}
}
cout << ans << endl;
return 0;
}