Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate text_io;
- use text_io::scan;
- use std::collections::VecDeque;
- fn main() {
- let mut _q: VecDeque<u32> = VecDeque::new();
- let mut _ans: Vec<i32> = vec![];
- let mut _n = 0;
- scan!("{}", _n);
- let mut _min: (u32, u32) = (0, 10001);
- for _i in 0.._n {
- let mut _command = 0;
- scan!("{}", _command);
- if _command == 0 {
- if _q.is_empty() {
- _ans.push(-1);
- } else {
- if _min.1 == 10001 {
- for _g in 0.._q.len() {
- if _q[_g] <= _min.1 {
- _min.1 = _q[_g];
- _min.0 = _g as u32;
- }
- }
- }
- _ans.push(_min.1 as i32);
- if _min.0 == 0 {
- _min.0 = 1;
- _min.1 = 10001;
- }
- _q.pop_front();
- _min.0 -= 1;
- }
- } else {
- _q.push_back(_command);
- if _command <= _min.1 {
- _min.0 = (_q.len()) as u32 - 1;
- _min.1 = _command;
- }
- }
- }
- for _i in _ans.iter() {
- println!("{}", _i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement