Skip to content

Commit 2b5fe1c

Browse files
committed
add abc415d.rs wrong answer
1 parent 6236e7f commit 2b5fe1c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/abc/abc415d.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+
use proconio::input;
3+
use proconio::marker::*;
4+
use std::cmp::Ordering;
5+
use std::cmp::Reverse;
6+
use std::collections::*;
7+
8+
fn main() {
9+
input! {
10+
mut n:usize,
11+
m:usize,
12+
mut ab:[(usize, usize);m],
13+
}
14+
15+
ab.sort_by(|a, b| {
16+
let v = (a.0-a.1).cmp(&(b.0-b.1));
17+
if v == Ordering::Equal {
18+
a.1.cmp(&b.1).reverse()
19+
} else {
20+
v
21+
}
22+
});
23+
// println!("{:?}", &ab);
24+
let mut count = 0;
25+
for (a,b) in ab {
26+
if a > n {
27+
continue;
28+
}
29+
let diff = a - b;
30+
let base_num = n - a;
31+
32+
let x = 1 + base_num / diff;
33+
count += x;
34+
n = b;
35+
}
36+
37+
38+
println!("{}", count);
39+
}

0 commit comments

Comments
 (0)