Skip to content

Commit

Permalink
abc272 e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Oct 22, 2022
1 parent 6ff6d47 commit b7dde58
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions abc272/src/bin/e.rs
@@ -1,10 +1,41 @@
use proconio::{input, marker::Usize1};
use std::collections::HashSet;

use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
m: usize,
a: [i64; n],
};
let ans = n - a.len();
println!("{}", ans);

let mut sets = vec![HashSet::new(); m];
for (i, a_i) in a.iter().copied().enumerate() {
let i = (i + 1) as i64;
let a_i = a_i + i;
let l = if a_i >= 0 { 0 } else { (-a_i + i - 1) / i } as usize;
let r = if a_i >= n as i64 {
0
} else {
(n as i64 - a_i + i - 1) / i
}
.min(m as i64)
.min(n as i64)
.max(0) as usize;

for j in l..r {
sets[j].insert((a_i + j as i64 * i) as usize);
}
}

for set in sets {
let mut b = vec![false; set.len() + 1];
for x in set.iter().copied() {
if x < set.len() {
b[x] = true;
}
}
let ans = b.iter().copied().position(|b_i| !b_i).unwrap();
println!("{}", ans);
}
}

0 comments on commit b7dde58

Please sign in to comment.