Skip to content

Commit

Permalink
agc011 a, b
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Feb 10, 2023
1 parent 96f334d commit e55048e
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 33 deletions.
88 changes: 86 additions & 2 deletions agc011/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agc011/Cargo.toml
@@ -1,11 +1,11 @@
[package]
name = "agc011"
version = "0.1.0"
authors = ["bouzuya <m@bouzuya.net>"]
edition = "2018"

# dependencies added to new project
[dependencies]
num = "=0.2.1"
proconio = { version = "=0.3.6", features = ["derive"] }
superslice = "=1.0.0"

Expand Down
24 changes: 12 additions & 12 deletions agc011/src/bin/a.rs
Expand Up @@ -3,24 +3,24 @@ use proconio::input;
fn main() {
input! {
n: usize,
c: usize,
capital_c: usize,
k: usize,
mut t: [usize; n],
};
t.sort();

let mut ans = 0;
let mut i_l = 0;
let mut i_r = 0;
while i_l < n {
while i_r + 1 < n && t[i_r + 1] <= t[i_l] + k {
i_r += 1;
}
ans += 1;
i_l += c;
if i_l > i_r {
i_l = i_r + 1;
let mut index = 0_usize;
let mut count = 0_usize;
while index < n {
let mut c = 0_usize;
let mut j = index;
while (j < n) && (t[j] <= t[index] + k) && (c < capital_c) {
c += 1;
j += 1;
}
count += 1;
index = j;
}
let ans = count;
println!("{}", ans);
}
20 changes: 10 additions & 10 deletions agc011/src/bin/b.rs
Expand Up @@ -3,20 +3,20 @@ use proconio::input;
fn main() {
input! {
n: usize,
mut a: [i64; n],
mut a: [usize; n],
};
a.sort();
let s = std::iter::once(0)
.chain(a.iter().scan(0, |acc, a_i| {
*acc += a_i;
let c = std::iter::once(0)
.chain(a.iter().scan(0, |acc, &i| {
*acc += i;
Some(*acc)
}))
.collect::<Vec<_>>();
let c = a
.iter()
.zip(s.iter())
.rposition(|(&a_i, &s_i)| s_i * 2 < a_i)
.collect::<Vec<usize>>();
let count = a
.into_iter()
.zip(c.into_iter())
.rposition(|(a_i, c_i)| a_i > c_i * 2)
.unwrap_or(0);
let ans = n - c;
let ans = n - count;
println!("{}", ans);
}
3 changes: 1 addition & 2 deletions agc011/src/bin/c.rs
@@ -1,5 +1,4 @@
use proconio::input;
use proconio::marker::Usize1;
use proconio::{input, marker::Usize1};

fn main() {
input! {
Expand Down
3 changes: 1 addition & 2 deletions agc011/src/bin/d.rs
@@ -1,5 +1,4 @@
use proconio::input;
use proconio::marker::Usize1;
use proconio::{input, marker::Usize1};

fn main() {
input! {
Expand Down
3 changes: 1 addition & 2 deletions agc011/src/bin/e.rs
@@ -1,5 +1,4 @@
use proconio::input;
use proconio::marker::Usize1;
use proconio::{input, marker::Usize1};

fn main() {
input! {
Expand Down
3 changes: 1 addition & 2 deletions agc011/src/bin/f.rs
@@ -1,5 +1,4 @@
use proconio::input;
use proconio::marker::Usize1;
use proconio::{input, marker::Usize1};

fn main() {
input! {
Expand Down

0 comments on commit e55048e

Please sign in to comment.