Skip to content

Commit d557fa1

Browse files
committed
Solve B in arc122
1 parent 19b8ea8 commit d557fa1

File tree

14 files changed

+1027
-0
lines changed

14 files changed

+1027
-0
lines changed

atcoder/rust/arc122/Cargo.lock

Lines changed: 638 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

atcoder/rust/arc122/Cargo.toml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[package]
2+
name = "arc122"
3+
version = "0.1.0"
4+
authors = ["k-yomo <kanji.yy@gmail.com>"]
5+
edition = "2018"
6+
7+
[package.metadata.cargo-compete]
8+
config = "../compete.toml"
9+
10+
[package.metadata.cargo-compete.bin]
11+
a = { name = "arc122-a", problem = { platform = "atcoder", contest = "arc122", index = "A", url = "https://atcoder.jp/contests/arc122/tasks/arc122_a" } }
12+
b = { name = "arc122-b", problem = { platform = "atcoder", contest = "arc122", index = "B", url = "https://atcoder.jp/contests/arc122/tasks/arc122_b" } }
13+
c = { name = "arc122-c", problem = { platform = "atcoder", contest = "arc122", index = "C", url = "https://atcoder.jp/contests/arc122/tasks/arc122_c" } }
14+
d = { name = "arc122-d", problem = { platform = "atcoder", contest = "arc122", index = "D", url = "https://atcoder.jp/contests/arc122/tasks/arc122_d" } }
15+
e = { name = "arc122-e", problem = { platform = "atcoder", contest = "arc122", index = "E", url = "https://atcoder.jp/contests/arc122/tasks/arc122_e" } }
16+
f = { name = "arc122-f", problem = { platform = "atcoder", contest = "arc122", index = "F", url = "https://atcoder.jp/contests/arc122/tasks/arc122_f" } }
17+
18+
[[bin]]
19+
name = "arc122-a"
20+
path = "src/bin/a.rs"
21+
22+
[[bin]]
23+
name = "arc122-b"
24+
path = "src/bin/b.rs"
25+
26+
[[bin]]
27+
name = "arc122-c"
28+
path = "src/bin/c.rs"
29+
30+
[[bin]]
31+
name = "arc122-d"
32+
path = "src/bin/d.rs"
33+
34+
[[bin]]
35+
name = "arc122-e"
36+
path = "src/bin/e.rs"
37+
38+
[[bin]]
39+
name = "arc122-f"
40+
path = "src/bin/f.rs"
41+
[dependencies]
42+
num = "=0.2.1"
43+
num-bigint = "=0.2.6"
44+
num-complex = "=0.2.4"
45+
num-integer = "=0.1.42"
46+
num-iter = "=0.1.40"
47+
num-rational = "=0.2.4"
48+
num-traits = "=0.2.11"
49+
num-derive = "=0.3.0"
50+
ndarray = "=0.13.0"
51+
nalgebra = "=0.20.0"
52+
alga = "=0.9.3"
53+
libm = "=0.2.1"
54+
rand = { version = "=0.7.3", features = ["small_rng"] }
55+
getrandom = "=0.1.14"
56+
rand_chacha = "=0.2.2"
57+
rand_core = "=0.5.1"
58+
rand_hc = "=0.2.0"
59+
rand_pcg = "=0.2.1"
60+
rand_distr = "=0.2.2"
61+
petgraph = "=0.5.0"
62+
indexmap = "=1.3.2"
63+
regex = "=1.3.6"
64+
lazy_static = "=1.4.0"
65+
ordered-float = "=1.0.2"
66+
ascii = "=1.0.0"
67+
permutohedron = "=0.2.4"
68+
superslice = "=1.0.0"
69+
itertools = "=0.9.0"
70+
itertools-num = "=0.1.3"
71+
maplit = "=1.0.2"
72+
either = "=1.5.3"
73+
im-rc = "=14.3.0"
74+
fixedbitset = "=0.2.0"
75+
bitset-fixed = "=0.1.0"
76+
proconio = { version = "=0.3.6", features = ["derive"] }
77+
text_io = "=0.1.8"
78+
whiteread = "=0.5.0"
79+
rustc-hash = "=1.1.0"
80+
smallvec = "=1.2.0"

atcoder/rust/arc122/src/bin/a.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}

atcoder/rust/arc122/src/bin/b.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
n: usize,
18+
a: [f64; n],
19+
}
20+
21+
let mut l = 0.0;
22+
let mut r = 1000000000.0;
23+
while (r - l) > 0.000001 {
24+
let ml = l + (r - l) / 3.0;
25+
let mr = r - (r - l) / 3.0;
26+
let ml_score = calc_score(&a, ml);
27+
let mr_score = calc_score(&a, mr);
28+
if ml_score > mr_score {
29+
l = ml;
30+
} else {
31+
r = mr;
32+
}
33+
}
34+
35+
println!("{}", calc_score(&a, l))
36+
}
37+
38+
fn calc_score(a: &Vec<f64>, x: f64) -> f64 {
39+
return a.iter().map(|&ai| x + ai - if ai > 2.0 * x { 2.0 * x } else { ai }).sum::<f64>() / a.len() as f64;
40+
}

atcoder/rust/arc122/src/bin/c.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}

atcoder/rust/arc122/src/bin/d.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}

atcoder/rust/arc122/src/bin/e.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}

atcoder/rust/arc122/src/bin/f.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![allow(unused_imports)]
2+
3+
use std::cmp::*;
4+
use std::collections::*;
5+
use std::io::Write;
6+
use std::ops::Bound::*;
7+
8+
use itertools::*;
9+
use itertools::__std_iter::once;
10+
use itertools_num::ItertoolsNum;
11+
use proconio::*;
12+
use proconio::marker::*;
13+
use superslice::*;
14+
15+
fn main() {
16+
input! {
17+
18+
}
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
type: Batch
3+
timelimit: 2s
4+
match: Lines
5+
6+
cases:
7+
- name: sample1
8+
in: |
9+
3
10+
3 1 5
11+
out: |
12+
15
13+
- name: sample2
14+
in: |
15+
4
16+
1 1 1 1
17+
out: |
18+
10
19+
- name: sample3
20+
in: |
21+
10
22+
866111664 178537096 844917655 218662351 383133839 231371336 353498483 865935868 472381277 579910117
23+
out: |
24+
279919144
25+
26+
extend: []
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
type: Batch
3+
timelimit: 2s
4+
match:
5+
Float:
6+
relative_error: 0.000001
7+
absolute_error: 0.000001
8+
9+
cases:
10+
- name: sample1
11+
in: |
12+
3
13+
3 1 4
14+
out: |
15+
1.83333333333333333333
16+
- name: sample2
17+
in: |
18+
10
19+
866111664 178537096 844917655 218662351 383133839 231371336 353498483 865935868 472381277 579910117
20+
out: |
21+
362925658.10000000000000000000
22+
23+
extend: []

0 commit comments

Comments
 (0)