🏇

# ABC203 write up

2021/05/31に公開

ABC203のバチャに参加したので解法とかを書きます

# A - Chinchirorin

a.rs
``````#![allow(unused_imports)]
#![allow(non_snake_case)]
use cmp::{max, min, Reverse};
use proconio::{fastout, input, marker::*};
use std::collections::*;
use std::*;

fn main() {
input! {
a:usize,
b:usize,
c:usize
}
println!(
"{}",
if a == b {
c
} else if b == c {
a
} else if a == c {
b
} else {
0
}
);
}
``````

# B - AtCoder Condominium

format!()を使ってi0jの形の数字を作って加算する．Rustはformat!()が便利なので良い...

b.rs
``````#![allow(unused_imports)]
#![allow(non_snake_case)]
use cmp::{max, min, Reverse};
use proconio::{fastout, input, marker::*};
use std::collections::*;
use std::*;

fn main() {
input! {
n:usize,
k:usize
}
let mut ans = 0;
for i in 1..=n {
for j in 1..=k {
let x:usize = format!("{}0{}",i,j).parse().unwrap();
ans += x;
}
}
println!("{}",ans);
}
``````

# C - Friends and Travel costs

c.rs
``````#![allow(unused_imports)]
#![allow(non_snake_case)]
use cmp::{max, min, Reverse};
use proconio::{fastout, input, marker::*};
use std::collections::*;
use std::*;

fn main() {
input! {
n:usize,
k:u64,
mut ab:[(u64,u64);n]
}
let mut nk = k;
let mut nx = 0;
let mut ans = 0;
ab.sort();
for (a, b) in ab {
if nk >= (a-nx) {
nk -= (a-nx);
nx = a;
nk += b;
}else{
break;
}
}
ans = nx + nk;
println!("{}", ans);
}
``````

ログインするとコメントできます