Submission #3230383
Source Code Expand
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
pub trait InputValue {
fn parse(s: &str) -> Self;
}
pub fn read<T: InputValue>() -> T {
let mut buf = String::new();
let _ = stdin().read_line(&mut buf);
T::parse(&buf.trim())
}
pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
let mut vec = vec![];
for _ in 0..n {
vec.push(read());
}
vec
}
pub fn readnc<T: InputValue>() -> Vec<T> {
let mut vec = vec![];
let line: String = read();
for token in line.split_whitespace() {
vec.push(T::parse(token));
}
vec
}
macro_rules! parse_single_value {
($($t:ty),*) => {
$(
impl InputValue for $t {
fn parse(s: &str) -> $t { s.parse().unwrap() }
}
)*
}
}
parse_single_value!(i32, i64, f32, f64, usize, String);
macro_rules! parse_tuple {
($($t:ident),*) => {
impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
fn parse(s: &str) -> ($($t),*) {
let mut tokens = s.split_whitespace();
let t = ($($t::parse(tokens.next().unwrap())),*);
t
}
}
}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);
// ===
const INF: usize = 100010;
fn main() {
let (n, c): (usize, usize) = read();
let mut ranges = vec![vec![]; c];
for _i in 0..n {
let (s, t, ci): (usize, usize, usize) = read();
ranges[ci-1].push((s, t));
}
let mut imo = vec![0; INF+10];
for i in 0..c {
ranges[i].sort();
let mut mod_ranges = vec![];
let mut last_s = INF;
let mut last_t = INF;
for &(s, t) in &ranges[i] {
if s == last_t {
last_t = t;
} else {
if last_t != INF {
mod_ranges.push((last_s, last_t));
}
last_s = s;
last_t = t;
}
}
if last_t != INF {
mod_ranges.push((last_s, last_t));
}
for (s, t) in mod_ranges {
imo[s] += 1;
imo[t+1] -= 1;
}
}
let mut ans = 0;
for i in 0..INF {
imo[i+1] += imo[i];
ans = max(ans, imo[i+1]);
}
println!("{}", ans);
}
Submission Info
Submission Time |
|
Task |
D - Recording |
User |
hamadu |
Language |
Rust (1.15.1) |
Score |
400 |
Code Size |
2431 Byte |
Status |
AC |
Exec Time |
35 ms |
Memory |
8444 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
34 ms |
6396 KB |
02.txt |
AC |
34 ms |
6396 KB |
03.txt |
AC |
34 ms |
6396 KB |
04.txt |
AC |
33 ms |
6396 KB |
05.txt |
AC |
35 ms |
6396 KB |
06.txt |
AC |
18 ms |
6396 KB |
07.txt |
AC |
13 ms |
6396 KB |
08.txt |
AC |
2 ms |
4352 KB |
09.txt |
AC |
34 ms |
6396 KB |
10.txt |
AC |
34 ms |
6396 KB |
11.txt |
AC |
34 ms |
6396 KB |
12.txt |
AC |
2 ms |
4352 KB |
13.txt |
AC |
2 ms |
4352 KB |
14.txt |
AC |
2 ms |
4352 KB |
15.txt |
AC |
2 ms |
4352 KB |
16.txt |
AC |
34 ms |
6396 KB |
17.txt |
AC |
34 ms |
6396 KB |
18.txt |
AC |
34 ms |
6396 KB |
19.txt |
AC |
35 ms |
8444 KB |
sample_01.txt |
AC |
2 ms |
4352 KB |
sample_02.txt |
AC |
2 ms |
4352 KB |
sample_03.txt |
AC |
2 ms |
4352 KB |