結果

問題 No.2155 みちらcolor
ユーザー tokumini_ss
提出日時 2022-12-09 21:33:03
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 7,198 ms
コンパイル使用メモリ 262,392 KB
最終ジャッジ日時 2025-02-09 07:28:39
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 64
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t N, M, L;
    cin >> N >> M >> L;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    const int64_t max_A = *max_element(A.begin(), A.end());
    const int64_t K = max(L, max_A);

    vector<bool> can_make(K + 1, false);
    can_make[L] = true;

    for (int64_t i = 0; i < N; i++) {
        vector<bool> next_can_make = can_make;
        for (int64_t j = 0; j <= K; j++) {
            if (can_make[j]) {
                const int64_t nj = (j + A[i]) / 2;
                next_can_make[nj] = true;
            }
        }
        can_make = next_can_make;
    }

    cout << (can_make[M] ? "Yes" : "No") << endl;
}
0