結果

問題 No.2422 regisys?
ユーザー zeronosu77108zeronosu77108
提出日時 2023-08-12 15:41:08
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 4,890 bytes
コンパイル時間 13,196 ms
コンパイル使用メモリ 403,788 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-04-30 09:59:01
合計ジャッジ時間 19,318 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,944 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 72 ms
16,512 KB
testcase_32 AC 93 ms
28,416 KB
testcase_33 AC 67 ms
15,224 KB
testcase_34 AC 36 ms
13,440 KB
testcase_35 AC 85 ms
17,536 KB
testcase_36 AC 65 ms
22,436 KB
testcase_37 AC 100 ms
29,140 KB
testcase_38 AC 62 ms
23,316 KB
testcase_39 AC 43 ms
16,484 KB
testcase_40 AC 44 ms
10,368 KB
testcase_41 AC 46 ms
15,616 KB
testcase_42 AC 154 ms
28,416 KB
testcase_43 AC 72 ms
19,944 KB
testcase_44 AC 166 ms
31,524 KB
testcase_45 AC 133 ms
26,616 KB
testcase_46 AC 163 ms
32,440 KB
testcase_47 AC 96 ms
23,112 KB
testcase_48 AC 170 ms
30,488 KB
testcase_49 AC 122 ms
28,092 KB
testcase_50 AC 157 ms
27,268 KB
testcase_51 AC 201 ms
47,668 KB
testcase_52 AC 73 ms
16,012 KB
testcase_53 AC 166 ms
33,072 KB
testcase_54 AC 211 ms
49,652 KB
testcase_55 AC 172 ms
34,748 KB
testcase_56 AC 129 ms
35,896 KB
testcase_57 AC 230 ms
54,236 KB
testcase_58 AC 229 ms
52,668 KB
testcase_59 AC 232 ms
53,676 KB
testcase_60 AC 231 ms
52,804 KB
testcase_61 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `a`
  --> src/main.rs:47:14
   |
47 |     for &(i,(a , b)) in ab.iter() {
   |              ^ help: if this is intentional, prefix it with an underscore: `_a`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `b`
  --> src/main.rs:56:18
   |
56 |     for &(i,(a , b)) in ab.iter() {
   |                  ^ help: if this is intentional, prefix it with an underscore: `_b`

warning: unused variable: `m`
  --> src/main.rs:67:25
   |
67 | fn solve_small(n:usize, m:usize, mut a:Vec<usize>, mut b:Vec<usize>, gg:Vec<usize>, mmma:Vec<usize>) {
   |                         ^ help: if this is intentional, prefix it with an underscore: `_m`

warning: unused variable: `b`
  --> src/main.rs:67:56
   |
67 | fn solve_small(n:usize, m:usize, mut a:Vec<usize>, mut b:Vec<usize>, gg:Vec<usize>, mmma:Vec<usize>) {
   |                                                        ^ help: if this is intentional, prefix it with an underscore: `_b`

warning: variable does not need to be mutable
  --> src/main.rs:67:34
   |
67 | fn solve_small(n:usize, m:usize, mut a:Vec<usize>, mut b:Vec<usize>, gg:Vec<usize>, mmma:Vec<usize>) {
   |                                  ----^
   |                                  |
   |                                  help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
  --> src/main.rs:67:52
   |
67 | fn solve_small(n:usize, m:usize, mut a:Vec<usize>, mut b:Vec<usize>, gg:Vec<usize>, mmma:Vec<usize>) {
   |                                                    ----^
   |                                                    |
   |                                                    help: remove this `mut`

ソースコード

diff #

use std::cmp::Reverse;
use std::collections::BinaryHeap;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.usize();
    let m = sc.usize();

    let a = sc.vec::<usize>(n);
    let b = sc.vec::<usize>(n);

    let mut g = BinaryHeap::new();
    let mut gg = vec![];
    let mut mma = BinaryHeap::new();
    let mut mmma = vec![];
    for _ in 0..m {
        let t = sc.u8();
        let c = sc.usize();
        if t == 0 { g.push(c); gg.push(c); }
        else { mma.push(c); mmma.push(c); }
    }


    if n <= 15 {
        solve_small(n, m, a, b, gg, mmma);
        return;
    }



    let mut ab = a.into_iter().zip(b.into_iter()).enumerate().collect::<Vec<_>>();



    let mut ok = vec![false; n];

    ab.sort_by_key(|&(_, (a,b))| (Reverse(a), Reverse(b)));
    for &(i,(a , b)) in ab.iter() {
        if a > b { continue }
        if !g.is_empty() && g.peek().unwrap() >= &a {
            g.pop();
            ok[i] = true;
        }
    }

    ab.sort_by_key(|&(_, (a,b))| (Reverse(b), Reverse(a)));
    for &(i,(a , b)) in ab.iter() {
        if ok[i] { continue; }
        if !mma.is_empty() && mma.peek().unwrap() >= &b {
            mma.pop();
            ok[i] = true;
        }
    }

    ab.sort_by_key(|&(_, (a,b))| (Reverse(a), Reverse(b)));
    for &(i,(a , b)) in ab.iter() {
        if ok[i] { continue; }
        if !g.is_empty() && g.peek().unwrap() >= &a {
            g.pop();
            ok[i] = true;
        }
    }

    println!("{}", ok.iter().filter(|&&x| !x).count());
}

fn solve_small(n:usize, m:usize, mut a:Vec<usize>, mut b:Vec<usize>, gg:Vec<usize>, mmma:Vec<usize>) {

    let mut ans = 0;
    for s in 0usize..1<<n {
        let mut t = s;
        while t != 0 {
            let g = (0..n).filter(|&i| (s>>i)&1==1 && (t>>i)&1==0).collect::<Vec<usize>>();
            let mma = (0..n).filter(|&i| (s>>i)&1==1 && (t>>i)&1==1).collect::<Vec<usize>>();

            let mut now = 0;
            let mut g = g.iter().map(|&i| a[i]).collect::<Vec<usize>>(); g.sort();
            for &g in g.iter() {
                while now < gg.len() && gg[now] < g { now += 1; }
                if now >= gg.len() { t = s & t.saturating_sub(1); continue; }
                now += 1;
            }

            let mut now = 0;
            let mut mma = mma.iter().map(|&i| a[i]).collect::<Vec<usize>>(); mma.sort();
            for &m in mma.iter() {
                while now < mmma.len() && mmma[now] < m { now += 1; }
                if now >= mmma.len() { t = s & t.saturating_sub(1); continue; }
                now += 1;
            }

            ans = ans.max(n - s.count_ones() as usize);
            t = s & t.saturating_sub(1);
        }
    }

    println!("{}", n - ans);
}

struct Scanner { s : std::collections::VecDeque<String> }
#[allow(unused)] impl Scanner { fn new() -> Self { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); Self { s : s.split_whitespace().map(|s| s.to_string()).collect() } } fn reload(&mut self) -> () { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); self.s = s.split_whitespace().map(|s| s.to_string()).collect(); } fn usize(&mut self) -> usize { self.input() } fn usize1(&mut self) -> usize { self.input::<usize>() - 1 } fn isize(&mut self) -> isize { self.input() } fn i32(&mut self) -> i32 { self.input() } fn i64(&mut self) -> i64 { self.input() } fn i128(&mut self) -> i128 { self.input() } fn u8(&mut self) -> u8 { self.input() } fn u32(&mut self) -> u32 { self.input() } fn u64(&mut self) -> u64 { self.input() } fn u128(&mut self) -> u128 { self.input() } fn edge(&mut self) -> (usize, usize) { (self.usize1(), self.usize1()) } fn edges(&mut self, m : usize) -> Vec<(usize, usize)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.edge()); } e } fn wedge<T:std::str::FromStr>(&mut self) -> (usize, usize, T) { (self.usize1(), self.usize1(), self.input()) } fn wedges<T:std::str::FromStr>(&mut self, m : usize) -> Vec<(usize, usize, T)> { let mut e = Vec::with_capacity(m); for _ in 0..m { e.push(self.wedge()); } e } fn input<T>(&mut self) -> T where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } if let Some(head) = self.s.pop_front() { head.parse::<T>().ok().unwrap() } else { panic!() } } fn tuple<T, U>(&mut self) -> (T, U) where T: std::str::FromStr, U: std::str::FromStr { (self.input(), self.input()) } fn vec<T>(&mut self, n: usize) -> Vec<T> where T: std::str::FromStr { if self.s.is_empty() { self.reload(); } self.s.drain(..n).map(|s| s.parse::<T>().ok().unwrap() ).collect::<Vec<T>>() } fn nvec<T>(&mut self) -> Vec<T> where T: std::str::FromStr { let n : usize = self.input(); self.vec(n) } fn chars(&mut self) -> Vec<char> { let s : String = self.input(); s.chars().collect() } fn bytes(&mut self) -> Vec<u8> { let s : String = self.input(); s.bytes().collect() } }
0