結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2019-12-18 16:07:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 970 bytes |
コンパイル時間 | 4,102 ms |
コンパイル使用メモリ | 112,804 KB |
実行使用メモリ | 27,452 KB |
最終ジャッジ日時 | 2024-07-06 13:27:27 |
合計ジャッジ時間 | 2,260 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; namespace No004_おもりと天秤 { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] weight = input.Select(int.Parse).ToArray(); int total = weight.Sum(); int sum = 0; if (total % 2 != 0) { Console.WriteLine("impossible"); return; } Array.Sort(weight); for (int i = 1; sum < total / 2; i++) { int[] w2 = new int[i + 1]; Array.Copy(weight, w2, i); sum = w2.Sum(); if (sum == total / 2) { Console.WriteLine("possible"); return; } } Console.WriteLine("impossible"); return; } } }