結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-29 02:06:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 850 bytes |
| コンパイル時間 | 5,228 ms |
| コンパイル使用メモリ | 111,716 KB |
| 実行使用メモリ | 27,460 KB |
| 最終ジャッジ日時 | 2024-11-27 13:24:33 |
| 合計ジャッジ時間 | 5,341 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 yuki0004 {
public class Program {
static internal string Solve(System.IO.TextReader reader) {
var n = int.Parse( reader.ReadLine() );
var w = reader.ReadLine().Split().ToList().ConvertAll( int.Parse )
.OrderByDescending(x=>x)
.ToList();
if (w.Sum() % 2 == 1) return "impossible";
var aim = w.Sum() / 2;
int subtotal=0;
for(var i = 0; i != n; ++i) {
if (subtotal + w[ i ] == aim) return "possible";
else if (subtotal + w[ i ] < aim) subtotal += w[ i ];
else continue;
}
return "impossible";
}
static void Main(string[] args) {
Console.WriteLine(Solve(System.Console.In));
}
}
}