結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
#include <iostream>
#include <cmath>
using namespace std;
using namespace atcoder;
using ll = long long;
using lb = long double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvll = vector<vector<ll>>;
using vP = vector<P>;
using Graph = vector<vector<ll>>;
using WGraph = vector<vector<pair<ll, ll>>>; // コスト、頂点番号の順
using mint = modint998244353;
//using mint = long double;
#define rep0(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
mt19937_64 rng(58);
long double PI = 3.14159265358979;
const ll LLMAX = 9223372036854775807;
const ll INF = 1e18;
vector<ll> di = {-1, 0, 1, 0}; // 上左下右
vector<ll> dj = {0, -1, 0, 1};
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    
    rep0 (ni, n) {
        ll p;
        cin >> p;

        if (p == 1) {
            if (a == 0) {
                cout << ni + 1 << endl;
                return 0;
            }
            a--;
        }
        else if (p == 2) {
            if (b == 0) {
                cout << ni + 1 << endl;
                return 0;
            }
            b--;
        }
        else {
            if (a == 0 || b == 0) {
                cout << ni + 1 << endl;
                return 0;
            }
            a--; b--;
        }
    }
    cout << -1 << endl;
    return 0;
}
0