Skip to content

Commit

Permalink
abc331 a, b, c, e
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 2, 2023
1 parent 8e71c8c commit 06f8768
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 0 deletions.
169 changes: 169 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/Cargo.lock

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

15 changes: 15 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/Cargo.toml
@@ -0,0 +1,15 @@
[package]
name = "abc331"
version = "0.1.0"
edition = "2021"

# dependencies added to new project
[dependencies]
ac-library-rs = "=0.1.1"
num = "=0.4.0"
proconio = { version = "=0.4.3", features = ["derive"] }
superslice = "=1.0.0"

[profile.release]
lto = true
panic = 'abort'
1 change: 1 addition & 0 deletions cargo-atcoder-1.70.0/contests/abc331/rust-toolchain
@@ -0,0 +1 @@
1.70.0
28 changes: 28 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/a.rs
@@ -0,0 +1,28 @@
use proconio::input;

fn main() {
input! {
capital_m: usize,
capital_d: usize,
y: usize,
m: usize,
d: usize,
};

let nd = if d == capital_d { 1 } else { d + 1 };
let nm = if d == capital_d {
if m == capital_m {
1
} else {
m + 1
}
} else {
m
};
let ny = if d == capital_d && m == capital_m {
y + 1
} else {
y
};
println!("{} {} {}", ny, nm, nd);
}
22 changes: 22 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/b.rs
@@ -0,0 +1,22 @@
use proconio::input;

fn main() {
input! {
n: usize,
s: usize,
m: usize,
l: usize,
};
let mut min = 1_000_000_000;
for a in 0..100 {
for b in 0..100 {
for c in 0..100 {
if 6 * a + 8 * b + 12 * c >= n {
min = min.min(s * a + m * b + l * c);
}
}
}
}
let ans = min;
println!("{}", ans);
}
21 changes: 21 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/c.rs
@@ -0,0 +1,21 @@
use proconio::input;
use superslice::Ext;

fn main() {
input! {
n: usize,
a: [usize; n],
};
let mut b = a.clone();
b.sort();
let c = std::iter::once(0)
.chain(b.iter().scan(0, |acc, &i| {
*acc += i;
Some(*acc)
}))
.collect::<Vec<usize>>();
for a_i in a.iter().copied() {
let index = b.lower_bound(&(a_i + 1));
println!("{}", c[n] - c[index]);
}
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/d.rs
@@ -0,0 +1,10 @@
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
a: [Usize1; n],
};
let ans = n - a.len();
println!("{}", ans);
}
45 changes: 45 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/e.rs
@@ -0,0 +1,45 @@
use std::collections::{HashMap, HashSet};

use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
m: usize,
l: usize,
a: [usize; n],
b: [usize; m],
cd: [(Usize1, Usize1); l],
};

let mut bi = b
.iter()
.enumerate()
.map(|(i, b_i)| (*b_i, i))
.collect::<Vec<(usize, usize)>>();
bi.sort_by_key(|(b_i, _)| *b_i);
bi.reverse();

let mut sets = HashMap::new();
for (c, d) in cd {
sets.entry(c).or_insert_with(HashSet::new).insert(d);
}

let mut max = 0_usize;
for (i, a_i) in a.iter().enumerate() {
match sets.get(&i) {
Some(set) => {
for (b_i, i) in bi.iter().copied() {
if !set.contains(&i) {
max = max.max(a_i + b_i);
break;
}
}
}
None => max = max.max(a_i + bi[0].0),
}
}

let ans = max;
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/f.rs
@@ -0,0 +1,10 @@
use proconio::{input, marker::Usize1};

fn main() {
input! {
n: usize,
a: [Usize1; n],
};
let ans = n - a.len();
println!("{}", ans);
}
10 changes: 10 additions & 0 deletions cargo-atcoder-1.70.0/contests/abc331/src/bin/g.rs
@@ -0,0 +1,10 @@
use proconio::{input, marker::Usize1};

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

0 comments on commit 06f8768

Please sign in to comment.