結果

問題 No.1071 ベホマラー
ユーザー hedwig100hedwig100
提出日時 2020-06-05 21:51:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 1,538 ms
コンパイル使用メモリ 172,144 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 20:52:45
合計ジャッジ時間 3,122 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 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 40 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 25 ms
5,376 KB
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 40 ms
5,376 KB
testcase_15 AC 48 ms
5,376 KB
testcase_16 AC 46 ms
5,376 KB
testcase_17 AC 47 ms
5,376 KB
testcase_18 AC 48 ms
5,376 KB
testcase_19 AC 46 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 44 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 44 ms
5,376 KB
testcase_24 AC 46 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |        ^~~

ソースコード

diff #

#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;
}
0