結果

問題 No.2851 Make Pairs
ユーザー NakLon131NakLon131
提出日時 2024-08-25 13:41:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 11,413 ms
コンパイル使用メモリ 407,352 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-25 13:41:15
合計ジャッジ時間 12,218 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 11 ms
6,812 KB
testcase_03 AC 10 ms
6,944 KB
testcase_04 AC 11 ms
6,944 KB
testcase_05 AC 9 ms
6,944 KB
testcase_06 AC 10 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    input!{
		n: usize,
		a: [usize; n],
	}

	// 1~nの個数を記録
	let mut cnt_a = vec![0; n+1];
	for &aa in &a {
		cnt_a[aa] += 1;
	}
	
	// 各値について、2で割った個数(切り捨て)を数える
	let mut cnt = 0;
	for &x in &cnt_a {
		cnt += x / 2;
	}
	println!("{}", cnt);
}
// 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