We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6236e7f commit 2b5fe1cCopy full SHA for 2b5fe1c
src/abc/abc415d.rs
@@ -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