結果

問題 No.29 パワーアップ
ユーザー abL8ZLsTbFabL8ZLsTbF
提出日時 2016-04-22 16:01:19
言語 C#
(csc 3.9.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 3,296 ms
使用メモリ 14,904 KB
最終ジャッジ日時 2022-11-27 23:16:29
合計ジャッジ時間 5,638 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 55 ms
14,868 KB
testcase_01 AC 54 ms
14,904 KB
testcase_02 AC 53 ms
14,636 KB
testcase_03 AC 54 ms
14,872 KB
testcase_04 AC 54 ms
14,716 KB
testcase_05 AC 55 ms
14,804 KB
testcase_06 AC 54 ms
14,732 KB
testcase_07 AC 53 ms
14,748 KB
testcase_08 AC 52 ms
14,788 KB
testcase_09 AC 51 ms
14,816 KB
testcase_10 AC 53 ms
14,800 KB
testcase_11 AC 54 ms
14,784 KB
testcase_12 AC 54 ms
14,692 KB
testcase_13 AC 53 ms
14,824 KB
testcase_14 AC 53 ms
14,848 KB
testcase_15 AC 51 ms
14,832 KB
testcase_16 AC 50 ms
14,860 KB
testcase_17 AC 52 ms
14,740 KB
testcase_18 AC 54 ms
14,892 KB
testcase_19 AC 53 ms
14,788 KB
testcase_20 AC 55 ms
14,768 KB
testcase_21 AC 54 ms
14,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Program {
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        int[] item = new int[10];
        for (int i = 0; i < 10; i++) item[i] = 0;
        for (int i = 0; i < n; i++) {
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(), value => int.Parse(value)-1);
            foreach (int temp in arr) item[temp]++;
        }
        int ans = 0;
        int rest = 0;
        for (int i = 0; i < 10; i++) {
            ans += (item[i] / 2);
            rest += item[i] % 2;
            if (rest >= 4) {
                ans += rest / 4;
                rest %= 4;
            }
        }
        Console.WriteLine(ans);
    }
}
0