結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2017-08-25 15:13:48 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,088 bytes |
コンパイル時間 | 1,314 ms |
コンパイル使用メモリ | 114,812 KB |
実行使用メモリ | 27,332 KB |
最終ジャッジ日時 | 2024-10-15 15:40:46 |
合計ジャッジ時間 | 2,757 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 6 |
コンパイルメッセージ
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 OmoriTenbin { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] P = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); string R = MainProcess(N, P); Console.WriteLine(R); } private static string MainProcess(int N, int[] P) { const string imp = "impossible"; const string pos = "possible"; int sum = 0; foreach(int p in P) sum += p; if (sum % 2 != 0) return imp; int hlf = sum / 2; int max = P.Max(); if (max > hlf) return imp; if (max == hlf) return pos; Array.Sort(P); for (int i = 0;i < N ; i++) { sum = 0; for (int j = i; j < N; j++) { sum += P[j]; if (sum == hlf) return pos; } } return imp; } } }