結果

問題 No.3453 Crape Shop
コンテスト
ユーザー ロロ宮
提出日時 2026-02-28 13:33:58
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,082 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,653 ms
コンパイル使用メモリ 362,576 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-28 13:34:09
合計ジャッジ時間 7,882 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#ifdef LOCAL
#include <library/my_library/utility/debug.hpp>
#else
#define debug(...)
#endif

using namespace std;
namespace rv = std::views;  // NOLINT

// clang-format off
using lint = long long;
using P = pair<lint, lint>;
#define ALL(a) (a).begin(), (a).end()

template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
inline void Yes(bool b = true) { println("{}",(b ? "Yes" : "No")); }
inline void No() { println("{}", "No");}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int ans = -1;
    for (int i = 0; i < N; i++) {
        int op;
        cin >> op;
        if (op == 1) {
            A--;
        } else if (op == 2) {
            B--;
        } else {
            A--;
            B--;
        }
        if (A < 0 || B < 0) {
            ans = i + 1;
            break;
        }
    }
    println("{}", ans);
}
0