結果

問題 No.29 パワーアップ
ユーザー itok217itok217
提出日時 2017-05-20 12:05:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 1,370 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 108,580 KB
実行使用メモリ 25,428 KB
最終ジャッジ日時 2023-10-19 04:09:24
合計ジャッジ時間 2,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,416 KB
testcase_01 AC 30 ms
25,416 KB
testcase_02 AC 30 ms
25,416 KB
testcase_03 AC 30 ms
25,416 KB
testcase_04 AC 29 ms
25,416 KB
testcase_05 AC 30 ms
25,428 KB
testcase_06 AC 30 ms
25,428 KB
testcase_07 AC 30 ms
25,428 KB
testcase_08 AC 30 ms
25,416 KB
testcase_09 AC 30 ms
25,416 KB
testcase_10 AC 30 ms
25,428 KB
testcase_11 AC 30 ms
25,428 KB
testcase_12 AC 30 ms
25,416 KB
testcase_13 AC 30 ms
25,428 KB
testcase_14 AC 30 ms
25,428 KB
testcase_15 AC 30 ms
25,428 KB
testcase_16 AC 30 ms
25,428 KB
testcase_17 AC 30 ms
25,416 KB
testcase_18 AC 30 ms
25,428 KB
testcase_19 AC 30 ms
25,428 KB
testcase_20 AC 29 ms
25,416 KB
testcase_21 AC 29 ms
25,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
    }
}
0