結果
問題 |
No.120 傾向と対策:門松列(その1)
|
ユーザー |
|
提出日時 | 2025-09-09 21:30:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 5,696 ms |
コンパイル使用メモリ | 207,348 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-09 21:30:35 |
合計ジャッジ時間 | 6,150 ms |
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
module main; // https://yukicoder.me/submissions/19181 より import std; void main() { // 入力 int T = readln.chomp.to!int; // キューの処理 foreach (_; 0 .. T) { int N = readln.chomp.to!int; auto L = readln.split.to!(long[]); long sum = 0; long[long] map; foreach (l; L) { if (l !in map) map[l] = 1; else ++map[l]; sum += l; } if (map.length < 3) { writeln(0); continue; } auto que = redBlackTree!("a > b", true, long)(map.values); long ans = 0; while (true) { long a = que.front; que.removeFront; long b = que.front; que.removeFront; long c = que.front; que.removeFront; if (c <= 0) { writeln(ans); break; } ++ans; que.insert([a - 1, b - 1, c - 1]); } } }