結果
問題 | No.2154 あさかつの参加人数 |
ユーザー | naut |
提出日時 | 2023-09-30 10:14:13 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 1,878 bytes |
コンパイル時間 | 2,071 ms |
コンパイル使用メモリ | 146,732 KB |
実行使用メモリ | 40,184 KB |
最終ジャッジ日時 | 2023-09-30 10:14:29 |
合計ジャッジ時間 | 12,689 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
40,176 KB |
testcase_01 | AC | 129 ms
40,176 KB |
testcase_02 | AC | 126 ms
40,160 KB |
testcase_03 | AC | 157 ms
40,136 KB |
testcase_04 | AC | 127 ms
40,184 KB |
testcase_05 | AC | 30 ms
4,376 KB |
testcase_06 | AC | 74 ms
17,952 KB |
testcase_07 | AC | 70 ms
26,168 KB |
testcase_08 | AC | 71 ms
29,960 KB |
testcase_09 | AC | 37 ms
21,468 KB |
testcase_10 | AC | 60 ms
23,780 KB |
testcase_11 | AC | 106 ms
36,096 KB |
testcase_12 | AC | 76 ms
24,072 KB |
testcase_13 | AC | 36 ms
10,020 KB |
testcase_14 | AC | 79 ms
22,808 KB |
testcase_15 | AC | 67 ms
28,528 KB |
testcase_16 | AC | 82 ms
27,300 KB |
testcase_17 | AC | 84 ms
22,500 KB |
testcase_18 | AC | 99 ms
29,664 KB |
testcase_19 | AC | 10 ms
5,916 KB |
testcase_20 | AC | 86 ms
30,832 KB |
testcase_21 | AC | 31 ms
19,644 KB |
testcase_22 | AC | 59 ms
36,712 KB |
testcase_23 | AC | 94 ms
30,328 KB |
testcase_24 | AC | 114 ms
35,420 KB |
ソースコード
#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>() }; } let N = input!(usize); let M = input!(usize); let mut cumsum: Vec<isize> = vec![0; N + 2]; for _ in 0..M { let l = input!(usize); let r = input!(usize); cumsum[r] += 1; cumsum[l + 1] -= 1; } let mut now = 0; let mut ans = vec![]; for i in 1..=N { now += cumsum[i]; ans.push(now); } writeln!( out, "{}", ans.iter() .rev() .map(|x| x.to_string()) .collect::<Vec<_>>() .join("\n") ); } struct Scanner<R> { reader: R, buf_str: Vec<u8>, buf_iter: str::SplitWhitespace<'static>, } impl<R: BufRead> Scanner<R> { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token<T: str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }