結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-13 14:25:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,193 bytes |
| コンパイル時間 | 967 ms |
| コンパイル使用メモリ | 116,960 KB |
| 実行使用メモリ | 28,168 KB |
| 最終ジャッジ日時 | 2024-11-17 04:47:42 |
| 合計ジャッジ時間 | 4,028 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 23 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OmoriToTenbin
{
class Program
{
public const int MaxOmoriWait = 100;
static bool IsPossible(int HalfData, int Number, string[] Data, bool[] OmoriFlag)
{
for (int a = 0; a < Data.Length; a++)
{
OmoriFlag[int.Parse(Data[a])] = true;
}
for (int a = 0; a < Data.Length; a++)
{
for (int b = 0; b < OmoriFlag.Length; b++)
{
if (OmoriFlag[b] == true)
{
if ((b + int.Parse(Data[a])) < (Number * MaxOmoriWait))
{
OmoriFlag[b + int.Parse(Data[a])] = true;
}
}
}
}
if (OmoriFlag[HalfData])
{
return true;
}
else
{
return false;
}
}
static int CreateHalf(string[] Data)
{
int half = 0;
for (int a = 0; a < Data.Length; a++)
{
half += int.Parse(Data[a]);
}
if ((half % 2) != 0)
{
return 0;
}
return half / 2;
}
static void Main(string[] args)
{
int Number;
Number = int.Parse(Console.ReadLine()); //標準入力
string[] Data = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
bool[] OmoriFlag = new bool[Number * MaxOmoriWait];
int HalfData = CreateHalf(Data);
if (HalfData == 0)
{
Console.WriteLine("impossible\n");
return;
}
if (IsPossible(HalfData, Number, Data, OmoriFlag))
{
Console.WriteLine("possible\n");
}
else
{
Console.WriteLine("impossible\n");
}
}
}
}