結果
問題 | No.497 入れ子の箱 |
ユーザー |
|
提出日時 | 2022-11-23 17:43:58 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 936 bytes |
コンパイル時間 | 12,641 ms |
コンパイル使用メモリ | 384,156 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 22:50:29 |
合計ジャッジ時間 | 14,343 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
fn main() {let mut n = String::new();std::io::stdin().read_line(&mut n).ok();let n: usize = n.trim().parse().unwrap();let mut boxes = (0..n).map(|_| {let mut temp = String::new();std::io::stdin().read_line(&mut temp).ok();let mut temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();temp.sort();temp.reverse();(temp[0], temp[1], temp[2])}).collect::<Vec<_>>();boxes.sort();let mut cnts = vec![0usize; n];cnts[0] = 1;for i in 1..n {let (x, y, z) = boxes[i];let mut maxval = 0usize;for j in 0..i {let (px, py, pz) = boxes[j];if px < x && py < y && pz < z {maxval = maxval.max(cnts[j]);}}cnts[i] = maxval + 1;}println!("{}", cnts.iter().max().unwrap());}