結果

問題 No.3049 Contest Coordinator
ユーザー NakLon131
提出日時 2025-03-08 10:23:15
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 1,404 bytes
コンパイル時間 13,505 ms
コンパイル使用メモリ 400,188 KB
実行使用メモリ 21,460 KB
最終ジャッジ日時 2025-03-08 10:23:39
合計ジャッジ時間 24,184 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    input!{
		n: usize, t: i64, x: i64, y: i64,
		mut d: [i64; n],
	}
	// dに番兵を追加
	d.push(1i64 << 60);

	let cost = min(x, y);

	// dは昇順にする
	d.sort();
	
	// 階差がtを超えたところで分割
	// 個数を記録していく
	let mut groups = Vec::new();
	let mut tail = 0;
	let mut top = 0;
	while tail < n {
		// 同じグループ
		while top < n && d[top+1] - d[top] <= t {
			top += 1;
		}
		// グループを分割
		groups.push(top + 1 - tail);
		top += 1;
		tail = top;
	}

	// グループ内の個数が多い順にする
	groups.sort(); groups.reverse();

	let mut cur = 0;
	let mut ans = Vec::new();
	for i in 0..groups.len() {
		for _ in 0..groups[i] {
			ans.push(cur);
		}
		cur += cost;
	}

	for i in 0..n-1 {
		print!("{} ", ans[i]);
	}
	println!("{}", ans[n-1]);
}

// const MOD17: usize = 1000000007;
// const MOD93: usize = 998244353;
// const INF: usize = 1 << 60;
// let dx = vec![!0, 0, 1, 0]; // 上左下右
// let dy = vec![0, !0, 0, 1]; // 上左下右
// let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右

#[allow(unused)]
use proconio::{input, marker::Chars, marker::Usize1};

#[allow(unused)]
use std::{
	mem::swap,
	cmp::min, cmp::max,
	cmp::Reverse,
	collections::HashSet, collections::BTreeSet,
	collections::HashMap, collections::BTreeMap,
	collections::BinaryHeap,
	collections::VecDeque,
	iter::FromIterator,
};
0