結果

問題 No.3453 Crape Shop
コンテスト
ユーザー norioc
提出日時 2026-02-28 13:58:35
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 947 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,501 ms
コンパイル使用メモリ 202,828 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-28 13:58:51
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#![allow(non_snake_case)]
#![allow(dead_code, unused_macros)]

use std::process::exit;
#[allow(unused_imports)]
use proconio::{input, marker::Usize1, marker::Chars};
#[allow(unused_imports)]
use itertools::Itertools;

macro_rules! d {
    ( $( $x:expr ),* $(,)? ) => {
        println!(
            concat!( $( stringify!($x), "={:?} " ),* ),
            $( $x ),*
        );
    };
}

fn main() {
    input! {
        N: usize,
        A: i64,
        B: i64,
        P: [i64; N],
    }

    let mut a = A;
    let mut b = B;
    for (i, &p) in P.iter().enumerate() {
        match p {
            1 => {
                a -= 1;
            },
            2 => {
                b -= 1;
            }
            3 => {
                a -= 1;
                b -= 1;
            }
            _ => unreachable!()
        }

        if a < 0 || b < 0 {
            println!("{}", i+1);
            exit(0);
        }
    }

    println!("-1");
}
0