結果

問題 No.1594 Three Classes
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-23 09:25:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 2,840 ms
コンパイル使用メモリ 107,248 KB
実行使用メモリ 28,604 KB
最終ジャッジ日時 2023-08-23 09:25:13
合計ジャッジ時間 7,872 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 346 ms
28,408 KB
testcase_01 AC 62 ms
22,048 KB
testcase_02 AC 63 ms
24,124 KB
testcase_03 AC 118 ms
26,452 KB
testcase_04 AC 358 ms
28,536 KB
testcase_05 AC 347 ms
28,560 KB
testcase_06 AC 62 ms
22,524 KB
testcase_07 AC 82 ms
26,496 KB
testcase_08 AC 350 ms
28,444 KB
testcase_09 AC 358 ms
28,604 KB
testcase_10 AC 347 ms
26,476 KB
testcase_11 AC 355 ms
28,544 KB
testcase_12 AC 354 ms
26,504 KB
testcase_13 AC 67 ms
20,232 KB
testcase_14 AC 236 ms
28,596 KB
testcase_15 AC 168 ms
24,356 KB
testcase_16 AC 97 ms
28,460 KB
testcase_17 AC 94 ms
24,404 KB
testcase_18 AC 63 ms
22,296 KB
testcase_19 AC 63 ms
22,368 KB
testcase_20 AC 65 ms
22,284 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.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var e = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            var c = true;
            for(var i = 0; i < (int)Math.Pow(3, n - 1); i++)
            {
                var sum = new long[3];
                var a = "";
                var k = i;
                while (k >= 3)
                {
                    a += (k % 3).ToString();
                    k /= 3;
                }
                a = k + a;
                while (a.Length < n)
                {
                    a = "0" + a;
                }
                for(var j = 0; j < n; j++)
                {
                    sum[a[j] - '0'] += e[j];
                }
                if (sum[0] == sum[1] && sum[1] == sum[2])
                {
                    Console.WriteLine("Yes");
                    c = false;
                    break;
                }
            }
            if (c)
            {
                Console.WriteLine("No");
            }
        }
    }
}
0