Skip to content

Commit bb72d63

Browse files
committed
Solve 070 in typical90
1 parent 2264d85 commit bb72d63

File tree

1 file changed

+13
-2
lines changed
  • atcoder/rust/typical90/src/bin

1 file changed

+13
-2
lines changed

atcoder/rust/typical90/src/bin/070.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,26 @@ use std::collections::*;
55
use std::io::Write;
66
use std::ops::Bound::*;
77

8-
use itertools::*;
98
use itertools::__std_iter::once;
9+
use itertools::*;
1010
use itertools_num::ItertoolsNum;
11-
use proconio::*;
1211
use proconio::marker::*;
12+
use proconio::*;
1313
use superslice::*;
1414

1515
fn main() {
1616
input! {
17+
n: usize,
18+
xy: [(i128, i128); n],
19+
}
20+
21+
let fac_x = xy.iter().map(|(x, _)| x).sorted().nth(n / 2).unwrap();
22+
let fac_y = xy.iter().map(|(_, y)| y).sorted().nth(n / 2).unwrap();
1723

24+
let mut total = 0;
25+
for (x, y) in xy.iter() {
26+
total += (x - fac_x).abs() + (y - fac_y).abs();
1827
}
28+
29+
println!("{}", total);
1930
}

0 commit comments

Comments
 (0)