結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2023-08-23 09:25:03 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 939 ms |
コンパイル使用メモリ | 113,576 KB |
実行使用メモリ | 33,308 KB |
最終ジャッジ日時 | 2024-12-21 11:02:55 |
合計ジャッジ時間 | 5,233 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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"); } } } }