結果
問題 |
No.1505 Zero-Product Ranges
|
ユーザー |
|
提出日時 | 2022-01-16 04:03:19 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 12,578 ms |
コンパイル使用メモリ | 379,080 KB |
実行使用メモリ | 15,360 KB |
最終ジャッジ日時 | 2024-11-22 15:30:46 |
合計ジャッジ時間 | 82,793 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 TLE * 17 |
ソースコード
#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let n: usize = parse_next!(input); let a: Vec<usize> = (0..n).map(|_| parse_next!(input)).collect(); let zeros = a .iter() .enumerate() .filter(|(_, x)| **x == 0) .map(|(i, _)| i) .collect::<Vec<_>>(); let ans = (|| { (0..n).fold(0, |acc, l| { acc + match zeros.iter().filter(|i| **i >= l).nth(0) { Some(i) => n - i, None => 0, } }) })(); println!("{}", ans); }