Skip to content

Commit b86803f

Browse files
committed
init
0 parents  commit b86803f

File tree

255 files changed

+4711
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+4711
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

Diff for: abc/Cargo.lock

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: abc/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "abc"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
proconio = { version = "0.4.3", features = ["derive"] }
10+
itertools = "0.10.3"
11+

Diff for: abc/src/abc019.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[allow(unused_imports)]
2+
use proconio::{
3+
fastout, input,
4+
marker::{Bytes, Chars, Isize1, Usize1},
5+
};
6+
#[fastout]
7+
pub fn main() {
8+
b()
9+
}
10+
11+
fn b() {
12+
input! {s:Chars}
13+
let mut temp = s[0];
14+
let mut cnt = 1;
15+
let mut ans = vec![];
16+
for i in 1..s.len() {
17+
if s[i] == temp {
18+
cnt += 1;
19+
} else {
20+
ans.push(format!("{}{}", temp, cnt));
21+
cnt = 1;
22+
temp = s[i];
23+
}
24+
if i == s.len() - 1 {
25+
ans.push(format!("{}{}", temp, cnt));
26+
}
27+
}
28+
println!("{}", ans.join(""));
29+
}

Diff for: abc/src/abc035.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use proconio::input;
2+
pub fn main() {
3+
input! {
4+
w:usize,
5+
h:usize
6+
}
7+
let mut point = 0;
8+
if w % 4 == 0 {
9+
point = w / 4;
10+
}
11+
if h / point == 3 {
12+
println!("4:3");
13+
} else {
14+
println!("16:9");
15+
}
16+
}

Diff for: abc/src/abc039.rs

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#[allow(unused_imports)]
2+
use proconio::{
3+
fastout, input,
4+
marker::{Bytes, Chars, Isize1, Usize1},
5+
};
6+
#[fastout]
7+
pub fn main() {
8+
input! {
9+
s:Chars
10+
}
11+
let mut white = false;
12+
let mut pos = "";
13+
let mut cur = 0;
14+
'outer: for i in 0..s.len() {
15+
if s[i] == 'W' {
16+
if !white {
17+
white = true
18+
} else {
19+
let mut b_count = 0;
20+
let mut inner_white = false;
21+
for j in i..s.len() {
22+
if s[j] == 'B' {
23+
b_count += 1;
24+
inner_white = false;
25+
} else {
26+
if !inner_white {
27+
inner_white = true;
28+
} else {
29+
if b_count == 2 {
30+
pos = "Si";
31+
cur = i;
32+
break 'outer;
33+
} else {
34+
pos = "Mi";
35+
cur = i;
36+
break 'outer;
37+
}
38+
}
39+
}
40+
}
41+
};
42+
} else {
43+
white = false
44+
}
45+
}
46+
while cur / 2 > 0 {
47+
cur -= 2;
48+
match pos {
49+
"Do" => {
50+
pos = "Si";
51+
continue;
52+
}
53+
"Re" => {
54+
pos = "Do";
55+
continue;
56+
}
57+
"Mi" => {
58+
pos = "Re";
59+
continue;
60+
}
61+
"Fa" => {
62+
pos = "Mi";
63+
continue;
64+
}
65+
"So" => {
66+
pos = "Fa";
67+
continue;
68+
}
69+
"La" => {
70+
pos = "So";
71+
continue;
72+
}
73+
"Si" => {
74+
pos = "La";
75+
continue;
76+
}
77+
_ => {}
78+
}
79+
}
80+
println!("{}", pos);
81+
}

Diff for: abc/src/abc121.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#[allow(unused_imports)]
2+
use proconio::{
3+
fastout, input,
4+
marker::{Bytes, Chars, Isize1, Usize1},
5+
};
6+
#[fastout]
7+
pub fn main() {
8+
input! {
9+
n:usize,
10+
mut m:usize,
11+
mut a:[(u64,u64);n],
12+
}
13+
14+
a.sort_by_key(|x| x.0);
15+
let mut res = 0;
16+
let mut temp = 0;
17+
loop {
18+
if m == 0 {
19+
break;
20+
}
21+
if a[temp].1 > 0 {
22+
res += a[temp].0;
23+
m -= 1;
24+
a[temp].1 -= 1;
25+
} else {
26+
temp += 1;
27+
}
28+
}
29+
println!("{}", res);
30+
}

Diff for: abc/src/abc169.rs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#[allow(unused_imports)]
2+
use proconio::{
3+
fastout, input,
4+
marker::{Bytes, Chars, Isize1, Usize1},
5+
};
6+
#[fastout]
7+
pub fn main() {
8+
input! {
9+
n:usize,
10+
a:[u128;n],
11+
}
12+
let mut ans = 1;
13+
let mut overflow = false;
14+
let mut zero = false;
15+
for i in 0..n {
16+
ans *= a[i];
17+
if ans > 10_u128.pow(18) {
18+
overflow = true;
19+
}
20+
if a[i] == 0 {
21+
zero = true;
22+
}
23+
}
24+
if zero {
25+
println!("0");
26+
} else if overflow {
27+
println!("-1");
28+
} else {
29+
println!("{}", ans);
30+
}
31+
}

Diff for: abc/src/abc171.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use std::collections::HashMap;
2+
3+
#[allow(unused_imports)]
4+
use proconio::{
5+
fastout, input,
6+
marker::{Bytes, Chars, Isize1, Usize1},
7+
};
8+
#[fastout]
9+
pub fn main() {
10+
input! {
11+
n:usize,
12+
a:[u64;n],
13+
q:usize
14+
}
15+
let mut m = HashMap::new();
16+
let mut sum = 0;
17+
for i in 0..n {
18+
let v = m.entry(a[i]).or_insert(0);
19+
*v += 1;
20+
sum += a[i];
21+
}
22+
for _ in 0..q {
23+
input! {
24+
b:u64,
25+
c:u64
26+
}
27+
let mut temp = 0;
28+
{
29+
let v = m.entry(b).or_insert(0);
30+
temp = *v;
31+
sum -= b * temp;
32+
*v = 0;
33+
}
34+
let v2 = m.entry(c).or_insert(0);
35+
*v2 += temp;
36+
sum += c * temp;
37+
println!("{:?}", sum);
38+
}
39+
}

Diff for: abc/src/abc223.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use proconio::input;
2+
pub fn main() {
3+
c();
4+
}
5+
6+
fn c() {
7+
input! {
8+
n:usize,
9+
d:[(f64,f64);n]
10+
}
11+
let mut time = 0.0;
12+
d.iter().for_each(|&(a, b)| {
13+
time += a / b;
14+
});
15+
time /= 2.0;
16+
let mut ans = 0.0;
17+
for i in 0..n {
18+
let t = d[i].0 / d[i].1;
19+
if t < time {
20+
time -= t;
21+
ans += d[i].0;
22+
} else {
23+
ans += d[i].1 * time;
24+
break;
25+
}
26+
}
27+
println!("{}", ans);
28+
}

Diff for: abc/src/abc226.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[allow(unused_imports)]
2+
use proconio::{
3+
fastout, input,
4+
marker::{Bytes, Chars, Isize1, Usize1},
5+
};
6+
#[fastout]
7+
pub fn main() {
8+
input! {}
9+
println!("{:?}", res);
10+
}

0 commit comments

Comments
 (0)