結果
| 問題 | No.365 ジェンガソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-01 17:32:52 |
| 言語 | Rust (1.93.0 + proconio + num + itertools) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| 記録 | |
| コンパイル時間 | 1,110 ms |
| コンパイル使用メモリ | 201,992 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-02-01 17:32:56 |
| 合計ジャッジ時間 | 3,743 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 25 |
ソースコード
fn main() {
let stdin = std::io::read_to_string(std::io::stdin()).unwrap();
let mut stdin = stdin.split_ascii_whitespace();
let n: usize = stdin.next().unwrap().parse().unwrap();
let a: Vec<u32> = (0..n)
.map(|_| stdin.next().unwrap().parse().unwrap())
.collect();
println!("{}", output(solve(a)));
}
fn solve(a: Vec<u32>) -> usize {
let n = a.len();
let mut lis = Vec::with_capacity(a.len());
a.into_iter().for_each(|a| {
let idx = mylib::lower_bound(&lis, &a);
if idx != lis.len() {
lis[idx] = a;
} else {
lis.push(a);
}
});
n - lis.len()
}
fn output(ans: usize) -> usize {
ans
}
mod mylib {
pub fn lower_bound<T: PartialOrd>(v: &[T], border: &T) -> usize {
if v.is_empty() || v[0] >= *border {
return 0;
}
let mut l: usize = 0;
let mut r: usize = v.len();
while l + 1 < r {
let c = (l + r) / 2;
if v[c] < *border {
l = c;
} else {
r = c;
}
}
r
}
}