結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-13 14:55:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,624 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 112,356 KB |
| 実行使用メモリ | 27,668 KB |
| 最終ジャッジ日時 | 2024-11-17 04:48:41 |
| 合計ジャッジ時間 | 2,148 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 c = 0; c < Data.Length; c++){
for (int a = 0; a < Data.Length; a++)
{
for (int b = OmoriFlag.Length - 1; b >= 0; b--)
{
if (OmoriFlag[b] == true)
{
if ((b + int.Parse(Data[a])) < (Number * MaxOmoriWait))
{
// if (b != int.Parse(Data[a]))
// {
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つ以上のスペース区切り入力の取得
*/
Number = 7;
string[] Data = { "20", "47", "73", "69", "26", "62", "89" };
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");
}
}
}
}