結果

問題 No.29 パワーアップ
ユーザー funakoshi
提出日時 2019-06-20 17:38:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 1,533 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 110,604 KB
実行使用メモリ 26,132 KB
最終ジャッジ日時 2024-12-17 22:16:40
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            int[] itemcnt = new int[10];
            int defeattime = int.Parse(n);
            int pupcnt = 0;
            for(int i=0;i<itemcnt.Length;i++)
            {
                itemcnt[i] = 0;
            }
            for(int i=0;i<defeattime;i++)
            {
                string item = Console.ReadLine();
                string[] itemary = item.Split(' ');
                int a = int.Parse(itemary[0]);
                int b = int.Parse(itemary[1]);
                int c = int.Parse(itemary[2]);
                itemcnt[a - 1] = itemcnt[a - 1]+1;
                itemcnt[b - 1] = itemcnt[b - 1]+1;
                itemcnt[c - 1] = itemcnt[c - 1]+1;
                
            }
            int cnt = 0;
            for (int i=0;i<itemcnt.Length;i++)
            {
                while (itemcnt[i] >= 2)
                {
                    itemcnt[i] = itemcnt[i] - 2;
                    pupcnt++;
                }
                if (itemcnt[i] == 1)
                {
                    itemcnt[i]--;
                    cnt++;
                }
                if (cnt == 4)
                {
                    pupcnt++;
                    cnt = 0;
                }
            }

            Console.WriteLine(pupcnt);
        }
    }
}
0