Skip to content

Commit 3710238

Browse files
committed
add abc413c.rs
1 parent 83086f3 commit 3710238

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/abc/abc413c.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+
use proconio::input;
3+
use proconio::marker::*;
4+
use std::marker::PhantomData;
5+
use std::cmp::*;
6+
use std::collections::*;
7+
8+
fn main() {
9+
input! {
10+
q:usize
11+
}
12+
13+
let mut que = VecDeque::new();
14+
for _ in 0..q {
15+
input! {
16+
t:usize
17+
}
18+
19+
if t == 1 {
20+
input! {
21+
c:isize,
22+
x:isize
23+
}
24+
25+
que.push_back((x, c));
26+
27+
continue
28+
}
29+
30+
input! {
31+
mut k:isize
32+
}
33+
34+
let mut result = 0isize;
35+
while 0 < k {
36+
if let Some((x,mut c)) = que.pop_front() {
37+
if k < c {
38+
c -= k;
39+
que.push_front((x, c));
40+
result += x * k;
41+
k = 0;
42+
} else if k == c {
43+
result += x * k;
44+
k = 0;
45+
} else {
46+
result += x * c;
47+
k -= c;
48+
}
49+
}
50+
}
51+
52+
println!("{}", result);
53+
}
54+
}

0 commit comments

Comments
 (0)