Skip to content

Commit dc51400

Browse files
committed
Solve C in abc102
1 parent bb72d63 commit dc51400

File tree

10 files changed

+903
-0
lines changed

10 files changed

+903
-0
lines changed

atcoder/rust/abc102/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/abc102/Cargo.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[package]
2+
name = "abc102"
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 = "abc102-a", problem = { platform = "atcoder", contest = "abc102", index = "A", url = "https://atcoder.jp/contests/abc102/tasks/abc102_a" } }
12+
b = { name = "abc102-b", problem = { platform = "atcoder", contest = "abc102", index = "B", url = "https://atcoder.jp/contests/abc102/tasks/abc102_b" } }
13+
c = { name = "abc102-c", problem = { platform = "atcoder", contest = "abc102", index = "C", url = "https://atcoder.jp/contests/abc102/tasks/arc100_a" } }
14+
d = { name = "abc102-d", problem = { platform = "atcoder", contest = "abc102", index = "D", url = "https://atcoder.jp/contests/abc102/tasks/arc100_b" } }
15+
16+
[[bin]]
17+
name = "abc102-a"
18+
path = "src/bin/a.rs"
19+
20+
[[bin]]
21+
name = "abc102-b"
22+
path = "src/bin/b.rs"
23+
24+
[[bin]]
25+
name = "abc102-c"
26+
path = "src/bin/c.rs"
27+
28+
[[bin]]
29+
name = "abc102-d"
30+
path = "src/bin/d.rs"
31+
[dependencies]
32+
num = "=0.2.1"
33+
num-bigint = "=0.2.6"
34+
num-complex = "=0.2.4"
35+
num-integer = "=0.1.42"
36+
num-iter = "=0.1.40"
37+
num-rational = "=0.2.4"
38+
num-traits = "=0.2.11"
39+
num-derive = "=0.3.0"
40+
ndarray = "=0.13.0"
41+
nalgebra = "=0.20.0"
42+
alga = "=0.9.3"
43+
libm = "=0.2.1"
44+
rand = { version = "=0.7.3", features = ["small_rng"] }
45+
getrandom = "=0.1.14"
46+
rand_chacha = "=0.2.2"
47+
rand_core = "=0.5.1"
48+
rand_hc = "=0.2.0"
49+
rand_pcg = "=0.2.1"
50+
rand_distr = "=0.2.2"
51+
petgraph = "=0.5.0"
52+
indexmap = "=1.3.2"
53+
regex = "=1.3.6"
54+
lazy_static = "=1.4.0"
55+
ordered-float = "=1.0.2"
56+
ascii = "=1.0.0"
57+
permutohedron = "=0.2.4"
58+
superslice = "=1.0.0"
59+
itertools = "=0.9.0"
60+
itertools-num = "=0.1.3"
61+
maplit = "=1.0.2"
62+
either = "=1.5.3"
63+
im-rc = "=14.3.0"
64+
fixedbitset = "=0.2.0"
65+
bitset-fixed = "=0.1.0"
66+
proconio = { version = "=0.3.6", features = ["derive"] }
67+
text_io = "=0.1.8"
68+
whiteread = "=0.5.0"
69+
rustc-hash = "=1.1.0"
70+
smallvec = "=1.2.0"

atcoder/rust/abc102/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/abc102/src/bin/b.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/abc102/src/bin/c.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 proconio::marker::*;
10+
use proconio::*;
11+
use superslice::*;
12+
13+
fn main() {
14+
input! {
15+
n: usize,
16+
mut a: [i128; n],
17+
}
18+
19+
for i in 0..n {
20+
a[i] -= (i + 1) as i128;
21+
}
22+
a.sort();
23+
let b = a[n / 2];
24+
25+
let mut min = 0;
26+
for (i, num) in a.iter().enumerate() {
27+
min += (num - b).abs();
28+
}
29+
30+
println!("{}", min);
31+
}

atcoder/rust/abc102/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+
}
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: Lines
5+
6+
cases:
7+
- name: sample1
8+
in: |
9+
3
10+
out: |
11+
6
12+
- name: sample2
13+
in: |
14+
10
15+
out: |
16+
10
17+
- name: sample3
18+
in: |
19+
999999999
20+
out: |
21+
1999999998
22+
23+
extend: []
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+
4
10+
1 4 6 3
11+
out: |
12+
5
13+
- name: sample2
14+
in: |
15+
2
16+
1000000000 1
17+
out: |
18+
999999999
19+
- name: sample3
20+
in: |
21+
5
22+
1 1 1 1 1
23+
out: |
24+
0
25+
26+
extend: []
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
type: Batch
3+
timelimit: 2s
4+
match: Lines
5+
6+
cases:
7+
- name: sample1
8+
in: |
9+
5
10+
2 2 3 5 5
11+
out: |
12+
2
13+
- name: sample2
14+
in: |
15+
9
16+
1 2 3 4 5 6 7 8 9
17+
out: |
18+
0
19+
- name: sample3
20+
in: |
21+
6
22+
6 5 4 3 2 1
23+
out: |
24+
18
25+
- name: sample4
26+
in: |
27+
7
28+
1 1 1 1 2 3 4
29+
out: |
30+
6
31+
32+
extend: []
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+
5
10+
3 2 4 1 2
11+
out: |
12+
2
13+
- name: sample2
14+
in: |
15+
10
16+
10 71 84 33 6 47 23 25 52 64
17+
out: |
18+
36
19+
- name: sample3
20+
in: |
21+
7
22+
1 2 3 1000000000 4 5 6
23+
out: |
24+
999999994
25+
26+
extend: []

0 commit comments

Comments
 (0)