Submission #61561401
Source Code Expand
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
fn main() {
input!{
n: usize,
mut a: [i64; n],
}
let mut imos = vec![0; n];
let mut current = 0;
for i in 0..n {
current += imos[i];
a[i] += current;
let left = n - i - 1;
let give = if a[i] > left as i64 { left as i64 } else { a[i] };
if give != left as i64{
imos[i+a[i] as usize+1] -= 1;
}
a[i] -= give;
current += 1;
}
println!("{}", a.iter().join(" "));
}
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()
.enumerate()
.map(|(i, x)| (format!("{:?}", x).len()).max(format!("{:?}", i).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
2025-01-11 21:17:23+0900
Task
D - Coming of Age Celebration
User
ardRiriy
Language
Rust (rustc 1.70.0)
Score
400
Code Size
2656 Byte
Status
AC
Exec Time
28 ms
Memory
17096 KiB
Compile Error
warning: the item `Itertools` is imported redundantly
--> src/main.rs:37:13
|
2 | use itertools::Itertools;
| -------------------- the item `Itertools` is already imported here
...
37 | use itertools::Itertools;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: the item `Itertools` is imported redundantly
--> src/main.rs:63:13
|
2 | use itertools::Itertools;
| -------------------- the item `Itertools` is already imported here
...
63 | use itertools::Itertools;
| ^^^^^^^^^^^^^^^^^^^^
warning: the item `Itertools` is imported redundantly
--> src/main.rs:72:13
|
2 | use itertools::Itertools;
| -------------------- the item `Itertools` is already imported here
...
72 | use itertools::Itertools;
| ^^^^^^^^^^^^^^^^^^^^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
400 / 400
Status
Set Name
Test Cases
Sample
sample00.txt, sample01.txt, sample02.txt
All
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt
Case Name
Status
Exec Time
Memory
sample00.txt
AC
0 ms
1972 KiB
sample01.txt
AC
1 ms
1864 KiB
sample02.txt
AC
0 ms
2000 KiB
testcase00.txt
AC
0 ms
1920 KiB
testcase01.txt
AC
18 ms
11828 KiB
testcase02.txt
AC
24 ms
14576 KiB
testcase03.txt
AC
23 ms
14360 KiB
testcase04.txt
AC
27 ms
17004 KiB
testcase05.txt
AC
8 ms
5736 KiB
testcase06.txt
AC
27 ms
17044 KiB
testcase07.txt
AC
22 ms
13824 KiB
testcase08.txt
AC
27 ms
17056 KiB
testcase09.txt
AC
23 ms
14544 KiB
testcase10.txt
AC
27 ms
17016 KiB
testcase11.txt
AC
11 ms
7412 KiB
testcase12.txt
AC
27 ms
17024 KiB
testcase13.txt
AC
17 ms
11148 KiB
testcase14.txt
AC
27 ms
16984 KiB
testcase15.txt
AC
4 ms
3456 KiB
testcase16.txt
AC
28 ms
17096 KiB
testcase17.txt
AC
23 ms
14388 KiB
testcase18.txt
AC
18 ms
11720 KiB
testcase19.txt
AC
16 ms
10992 KiB