結果
問題 | No.29 パワーアップ |
ユーザー |
|
提出日時 | 2017-05-20 12:05:58 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 1,370 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 104,960 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-09-19 00:25:00 |
合計ジャッジ時間 | 2,272 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; class AOJ { static void Main() { int n = int.Parse(Console.ReadLine()); int[] items = new int[11]; for (int i = 0; i < n; i++) { int[] acquired_items = Console.ReadLine().Split().Select(int.Parse).ToArray(); foreach (var elem in acquired_items) { items[elem]++; } } int cnt = 0; while (true) { bool power_up = false; for (int i = 1; i <= 10; i++) { if(items[i] >= 2) { cnt++; items[i] -= 2; power_up = true; } } if (power_up == false) { break; } } while (true) { bool power_up = false; List<int> tmp = new List<int>(); for (int i = 1; i <= 10; i++) { if(items[i] != 0) { tmp.Add(i); } } if(tmp.Count >= 4) { cnt++; for (int i = 0; i < 4; i++) { items[tmp[i]]--; } power_up = true; } if (power_up == false) { break; } } Console.WriteLine(cnt); } }