結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-31 18:04:28 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 834 bytes |
| コンパイル時間 | 1,917 ms |
| コンパイル使用メモリ | 110,536 KB |
| 実行使用メモリ | 27,196 KB |
| 最終ジャッジ日時 | 2024-09-14 22:07:52 |
| 合計ジャッジ時間 | 2,421 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 4 |
コンパイルメッセージ
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 _19._10._31._4
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Array.Sort(a);
if (a.Sum() % 2 == 0 && n > 1)
{
int sum1 = a[n - 1]; int sum2 = a[n - 2];
for (int i = n - 3; i >= 0; i--)
{
if (sum1 < sum2)
sum1 += a[i];
else
sum2 += a[i];
}
if (sum1 == sum2)
{ Console.WriteLine("possible"); return; }
}
Console.WriteLine("impossible");
}
}
}