Submission #46809657


Source Code Expand

#![allow(dead_code)]

use std::{cmp::Reverse, collections::BinaryHeap};
fn main() {
    proconio::input! {
        n: usize,
        mut td: [(usize, usize); n]
    }
    let mut ev = vec![];
    for (i, (t, d)) in td.into_iter().enumerate() {
        ev.push((t, t + d, i));
    }

    ev.sort();

    let mut total = 0;
    let mut waiting = BinaryHeap::new();
    let mut last_time = 0;
    for (t, td, i) in ev.into_iter() {
        while last_time < t {
            if let Some((Reverse(ptd), pi)) = waiting.pop() {
                if last_time <= ptd {
                    total += 1;
                    last_time += 1;
                }
            } else {
                break;
            }
        }
        waiting.push((Reverse(td), i));
        last_time = t;
    }
    while let Some((Reverse(ptd), pi)) = waiting.pop() {
        if last_time <= ptd {
            total += 1;
            last_time += 1;
        }
    }
    println!("{}", total);
}

Submission Info

Submission Time
Task D - Printing Machine
User Lenqth
Language Rust (rustc 1.70.0)
Score 450
Code Size 966 Byte
Status AC
Exec Time 57 ms
Memory 15932 KiB

Compile Error

warning: unused variable: `pi`
  --> src/main.rs:21:40
   |
21 |             if let Some((Reverse(ptd), pi)) = waiting.pop() {
   |                                        ^^ help: if this is intentional, prefix it with an underscore: `_pi`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `pi`
  --> src/main.rs:33:35
   |
33 |     while let Some((Reverse(ptd), pi)) = waiting.pop() {
   |                                   ^^ help: if this is intentional, prefix it with an underscore: `_pi`

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 47
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 02_random2_20.txt, 02_random2_21.txt, 02_random2_22.txt, 02_random2_23.txt, 02_random2_24.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 03_random3_06.txt, 03_random3_07.txt, 03_random3_08.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 0 ms 1996 KiB
00_sample_01.txt AC 0 ms 1796 KiB
00_sample_02.txt AC 0 ms 1912 KiB
01_random_00.txt AC 44 ms 15508 KiB
01_random_01.txt AC 14 ms 6412 KiB
01_random_02.txt AC 32 ms 12132 KiB
01_random_03.txt AC 39 ms 14220 KiB
01_random_04.txt AC 30 ms 11364 KiB
02_random2_00.txt AC 47 ms 14664 KiB
02_random2_01.txt AC 57 ms 14732 KiB
02_random2_02.txt AC 57 ms 14412 KiB
02_random2_03.txt AC 56 ms 14500 KiB
02_random2_04.txt AC 56 ms 14340 KiB
02_random2_05.txt AC 45 ms 14744 KiB
02_random2_06.txt AC 54 ms 14636 KiB
02_random2_07.txt AC 54 ms 14468 KiB
02_random2_08.txt AC 54 ms 14404 KiB
02_random2_09.txt AC 54 ms 14296 KiB
02_random2_10.txt AC 46 ms 14616 KiB
02_random2_11.txt AC 53 ms 14492 KiB
02_random2_12.txt AC 52 ms 14480 KiB
02_random2_13.txt AC 53 ms 14332 KiB
02_random2_14.txt AC 51 ms 14212 KiB
02_random2_15.txt AC 44 ms 14540 KiB
02_random2_16.txt AC 50 ms 14536 KiB
02_random2_17.txt AC 51 ms 14380 KiB
02_random2_18.txt AC 50 ms 14192 KiB
02_random2_19.txt AC 50 ms 14136 KiB
02_random2_20.txt AC 38 ms 13876 KiB
02_random2_21.txt AC 39 ms 13840 KiB
02_random2_22.txt AC 37 ms 13928 KiB
02_random2_23.txt AC 37 ms 13956 KiB
02_random2_24.txt AC 37 ms 14016 KiB
03_random3_00.txt AC 43 ms 13868 KiB
03_random3_01.txt AC 43 ms 14068 KiB
03_random3_02.txt AC 45 ms 14060 KiB
03_random3_03.txt AC 44 ms 13992 KiB
03_random3_04.txt AC 44 ms 13904 KiB
03_random3_05.txt AC 45 ms 13920 KiB
03_random3_06.txt AC 43 ms 14024 KiB
03_random3_07.txt AC 43 ms 14008 KiB
03_random3_08.txt AC 44 ms 14036 KiB
04_handmade_00.txt AC 34 ms 15932 KiB
04_handmade_01.txt AC 37 ms 13960 KiB
04_handmade_02.txt AC 37 ms 13944 KiB
04_handmade_03.txt AC 0 ms 2036 KiB
04_handmade_04.txt AC 43 ms 13336 KiB