結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-31 18:01:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 832 bytes |
| コンパイル時間 | 893 ms |
| コンパイル使用メモリ | 114,124 KB |
| 実行使用メモリ | 27,304 KB |
| 最終ジャッジ日時 | 2024-09-14 22:07:49 |
| 合計ジャッジ時間 | 2,298 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 12 |
コンパイルメッセージ
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");
}
}
}