結果

問題 No.29 パワーアップ
ユーザー n.yn.y
提出日時 2022-06-08 11:10:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 2,530 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 108,924 KB
実行使用メモリ 24,132 KB
最終ジャッジ日時 2023-10-21 04:00:46
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,132 KB
testcase_01 AC 25 ms
24,132 KB
testcase_02 AC 25 ms
24,132 KB
testcase_03 AC 26 ms
24,132 KB
testcase_04 AC 26 ms
24,132 KB
testcase_05 AC 26 ms
24,132 KB
testcase_06 AC 26 ms
24,132 KB
testcase_07 AC 26 ms
24,132 KB
testcase_08 AC 26 ms
24,132 KB
testcase_09 AC 25 ms
24,132 KB
testcase_10 AC 25 ms
24,132 KB
testcase_11 AC 26 ms
24,132 KB
testcase_12 AC 25 ms
24,132 KB
testcase_13 AC 25 ms
24,132 KB
testcase_14 AC 25 ms
24,132 KB
testcase_15 AC 25 ms
24,132 KB
testcase_16 AC 25 ms
24,132 KB
testcase_17 AC 25 ms
24,132 KB
testcase_18 AC 26 ms
24,132 KB
testcase_19 AC 25 ms
24,132 KB
testcase_20 AC 26 ms
24,132 KB
testcase_21 AC 25 ms
24,132 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.Diagnostics;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //敵を倒す回数
            int N = int.Parse(Console.ReadLine());

            //獲得したアイテムを収納する
            int[] s = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            //獲得アイテム
            int[] n =new int[3];

            //敵を倒す回数分ループ
            for (int x = 0; x < N; x++)
            {
                //敵を倒す1回分 入力して配列
                string[] str = Console.ReadLine().Split(' ');

                //アイテム番号を配列に入れる
                for (int i = 0; i < 3; i++)
                {
                    int a = int.Parse(str[i]);
                    n[i] = a;
                }

                //獲得したアイテムを収納する 
                for (int j = 1; j <= 10; j++)
                {

                    for (int k = 1; k <= 3; k++)
                    {
                        //同じ数字なら
                        if (j == n[k - 1])
                        {
                            //プラス1する
                            s[j - 1] += 1;
                        }
                    }
                    //Debug.WriteLine(s[j - 1]);

                }
            }

            //合計値
            int num = 0;
            int num1 = 0;
            int num2 = 0;
            //あまりの数字を入れる
            int ans2 = 0;
            //獲得したアイテムを収納した個数
            for (int i=1;i<=10;i++)
            {
                //割ったもの
                int ans = 0;
                int ans1 = 0;
                int ans3 = 0;
                //同じ数字が2つあれば、パワーアップする
                ans = s[i - 1] / 2;
                num += ans;
                //余れば
                ans1 = s[i - 1] % 2;

                if(ans1>0)
                {
                    //余った数字をans2に入れる
                    ans2 += ans1;
                }

                //10まで調べて、余った数字を4で割る
                if(i==10)
                {
                    ans3 = ans2 / 4;
                    num1 += ans3;

                    //パワーアップした分の合計を求める
                    num2 = num + num1;

                }

            }
            Console.WriteLine(num2.ToString());
        }
    }
}
0