結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2016-07-30 21:15:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,034 bytes |
コンパイル時間 | 1,232 ms |
コンパイル使用メモリ | 104,832 KB |
実行使用メモリ | 26,264 KB |
最終ジャッジ日時 | 2024-04-24 13:13:37 |
合計ジャッジ時間 | 2,230 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
26,012 KB |
testcase_01 | AC | 21 ms
23,920 KB |
testcase_02 | AC | 22 ms
26,264 KB |
testcase_03 | WA | - |
testcase_04 | AC | 22 ms
24,224 KB |
testcase_05 | AC | 22 ms
26,260 KB |
testcase_06 | AC | 22 ms
24,056 KB |
testcase_07 | AC | 23 ms
26,224 KB |
testcase_08 | AC | 22 ms
24,092 KB |
testcase_09 | AC | 22 ms
23,968 KB |
testcase_10 | AC | 21 ms
24,056 KB |
testcase_11 | AC | 21 ms
22,076 KB |
testcase_12 | AC | 22 ms
24,208 KB |
testcase_13 | AC | 21 ms
23,800 KB |
testcase_14 | AC | 21 ms
24,116 KB |
testcase_15 | AC | 21 ms
24,216 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 48 ms
24,048 KB |
testcase_19 | AC | 21 ms
24,180 KB |
testcase_20 | AC | 21 ms
24,112 KB |
testcase_21 | AC | 21 ms
26,224 KB |
testcase_22 | AC | 21 ms
24,088 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; namespace OmoriToTenbin2 { class Program { static int N; static int[] weightCount; static int[] remainSum; static void Main(string[] args) { N = int.Parse(Console.ReadLine()); string[] w = Console.ReadLine().Split(' '); weightCount = new int[101]; remainSum = new int[101]; for(int i = 0; i < N; i++) { int j = int.Parse(w[i]); weightCount[j] = ~weightCount[j] & 0x01; } //for (int i = 1; i <= 100; i++) // Console.WriteLine(weightCount[i]); remainSum[1] = weightCount[1]; for(int i=2; i <= 100; i++) { remainSum[i] = remainSum[i - 1] + i * weightCount[i]; } if(Search(0, 100)) { Console.WriteLine("possible"); } else { Console.WriteLine("impossible"); } } static bool Search(int weight, int w) { if(w == 1) { if(weightCount[1] == 0) { if (weight == 0) { return true; } } else { if(weight+1 == 0 || weight -1 == 0) { return true; } } return false; } if(Math.Abs(weight) > remainSum[w]) { return false; } if(weightCount[w] == 0) { return Search(weight, w - 1); } if(Search(weight-w, w-1)) { return true; } if (Search(weight + w, w - 1)) { return true; } return false; } } }