結果
| 問題 | No.568 じゃんじゃん 落とす 委員会 |
| コンテスト | |
| ユーザー |
Ons
|
| 提出日時 | 2023-12-17 14:19:11 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,258 bytes |
| 記録 | |
| コンパイル時間 | 13,625 ms |
| コンパイル使用メモリ | 390,424 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-27 08:00:47 |
| 合計ジャッジ時間 | 15,247 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
use std::io::stdin;
const INF: usize = 1000000000;
fn main() {
let mut input = stdin().lines().map(|s| s.unwrap());
let s = input.next().unwrap();
let mut s = s.split_whitespace();
let n: usize = s.next().unwrap().parse().unwrap();
let m: usize = s.next().unwrap().parse().unwrap();
let mut x = Vec::with_capacity(n);
let mut a = Vec::with_capacity(n);
let mut b = Vec::with_capacity(n);
for line in input.take(n) {
let mut line = line.split_whitespace();
let xi: usize = line.next().unwrap().parse().unwrap();
let ai: usize = line.next().unwrap().parse().unwrap();
let bi: usize = line.next().unwrap().parse().unwrap();
x.push(xi);
a.push(ai);
b.push(bi);
}
let mut x = x;
let a = a;
let b = b;
let mut by_a: Vec<_> = (0..n).collect();
by_a.sort_by_key(|&i| a[i]);
let by_a = by_a;
let mut by_b: Vec<_> = (0..n).collect();
by_b.sort_by_key(|&i| b[i]);
let by_b = by_b;
let mut res = INF;
let mut two = 0;
let mut three = 0;
for xi in &mut x {
// のちのループが sa = 0, sb = max から始まるので、全員がちょうど xi + 1 個の問題を解ける
*xi += 1;
if *xi >= 2 {
two += 1;
}
if *xi >= 3 {
three += 1;
}
}
let mut by_a_i = 0;
let mut by_b_i = n;
let mut sb = 100001;
for sa in 0..100002 {
while by_a_i < n && a[by_a[by_a_i]] < sa {
let i = by_a[by_a_i];
x[i] -= 1;
if x[i] == 1 {
two -= 1;
}
if x[i] == 2 {
three -= 1;
}
by_a_i += 1;
}
while two < m && sb > 0 {
sb -= 1;
while by_b_i > 0 && b[by_b[by_b_i - 1]] >= sb {
by_b_i -= 1;
let i = by_b[by_b_i];
x[i] += 1;
if x[i] == 2 {
two += 1;
}
if x[i] == 3 {
three += 1;
}
}
}
// println!("sa: {}, sb: {}, t: {}", sa, sb, three);
res = res.min(three);
}
println!("{}", res);
}
Ons