Submission #60504341
Source Code Expand
#[allow(unused_imports)]
use proconio::input;
fn main() {
input!{
n: usize,
v: [(usize, u64); n],
}
let mut t = 0;
let mut i = 0;
let mut l = 0;
while i < n {
if l != 0 {
l -= 1;
}
if t == v[i].0 {
l += v[i].1;
i += 1;
}
t += 1;
}
println!("{l}");
}
pub trait Debuggable {
fn debug_string(&self) -> String;
}
impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for Vec<T> {
fn debug_string(&self) -> String {
use itertools::Itertools;
use std::iter::repeat;
if let Some(max_size) = self.iter()
.map(|x| format!("{:?}", x).len())
.max() {
let mut idx = String::from("idx |");
let mut val = String::from("val |");
for (i, xi) in self.iter().enumerate() {
idx.push_str(
&format!(" {:>w$} |", i, w=max_size)
);
val.push_str(
&format!(" {:>w$} |", xi, w=max_size)
);
}
format!("{}\n{}\n{}\n", idx, repeat('-').take(idx.len()).join(""), val)
} else {
format!("idx | \nval |\n")
}
}
}
impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for std::collections::BTreeSet<T> {
fn debug_string(&self) -> String {
use itertools::Itertools;
format!("{{ {} }}", self.iter().join(", "))
}
}
impl<T, U> Debuggable for std::collections::BTreeMap<T, U>
where T: std::fmt::Debug + std::fmt::Display, U: std::fmt::Debug + std::fmt::Display
{
fn debug_string(&self) -> String {
use itertools::Itertools;
format!(
"{{\n{}\n }}", self.iter()
.map(|(k, v)| format!("{k} -> {v}, "))
.join("\n")
)
}
}
// lg! マクロの定義
#[macro_export]
macro_rules! lg {
($val:expr) => {
#[cfg(feature = "local")]
{
{
use Debuggable;
let val = &$val;
eprintln!(
"[{}:{}] {} = \n{}",
file!(),
line!(),
stringify!($val),
val.debug_string()
);
val
}
}
}
}
Submission Info
Submission Time |
|
Task |
A - Humidifier 1 |
User |
ardRiriy |
Language |
Rust (rustc 1.70.0) |
Score |
150 |
Code Size |
2410 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
2044 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
150 / 150 |
Status |
|
|
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_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
1912 KiB |
00_sample_01.txt |
AC |
1 ms |
1928 KiB |
00_sample_02.txt |
AC |
1 ms |
2044 KiB |
01_test_00.txt |
AC |
1 ms |
1928 KiB |
01_test_01.txt |
AC |
1 ms |
1780 KiB |
01_test_02.txt |
AC |
1 ms |
1956 KiB |
01_test_03.txt |
AC |
1 ms |
1924 KiB |
01_test_04.txt |
AC |
1 ms |
1928 KiB |
01_test_05.txt |
AC |
1 ms |
1792 KiB |
01_test_06.txt |
AC |
1 ms |
1896 KiB |
01_test_07.txt |
AC |
1 ms |
1956 KiB |
01_test_08.txt |
AC |
1 ms |
1860 KiB |
01_test_09.txt |
AC |
1 ms |
1992 KiB |
01_test_10.txt |
AC |
1 ms |
1924 KiB |
01_test_11.txt |
AC |
1 ms |
1924 KiB |
01_test_12.txt |
AC |
1 ms |
1924 KiB |
01_test_13.txt |
AC |
1 ms |
1924 KiB |
01_test_14.txt |
AC |
1 ms |
1912 KiB |
01_test_15.txt |
AC |
1 ms |
1928 KiB |
01_test_16.txt |
AC |
1 ms |
1924 KiB |