結果

問題 No.2918 Divide Applicants Fairly
ユーザー magurofly
提出日時 2024-10-10 12:45:26
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
MLE  
実行時間 -
コード長 502 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,370 ms
コンパイル使用メモリ 194,004 KB
実行使用メモリ 566,096 KB
最終ジャッジ日時 2026-04-26 14:38:02
合計ジャッジ時間 6,787 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other MLE * 1 -- * 60
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use proconio::input;
use std::collections::HashSet;

fn main() {
	input! {
		n: usize,
		rating: [i64; n],
	}
	
	let mut dp = HashSet::new();
	let mut add = vec![];
	for &r in &rating {
		add.push((1, r));
		add.push((-1, -r));
		for &(x, y) in &dp {
			add.push((x + 1, y + r));
			add.push((x - 1, y - r));
		}
		
		for x in add.drain(..) {
			dp.insert(x);
		}
	}
	
	let mut ans = 1_000_000_000_000_000_000;
	for (x, y) in dp {
		if x == 0 {
			ans = ans.min(y.abs());
		}
	}
	
	println!("{ans}");
}
0