結果

問題 No.4 おもりと天秤
ユーザー kuroi_13kuroi_13
提出日時 2017-01-27 11:25:31
言語 Perl
(5.38.2)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 445 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 5,956 KB
最終ジャッジ日時 2023-09-08 17:18:14
合計ジャッジ時間 1,610 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,940 KB
testcase_01 AC 5 ms
4,968 KB
testcase_02 AC 6 ms
5,092 KB
testcase_03 AC 5 ms
4,956 KB
testcase_04 AC 5 ms
5,000 KB
testcase_05 AC 44 ms
5,956 KB
testcase_06 AC 5 ms
4,968 KB
testcase_07 AC 44 ms
5,840 KB
testcase_08 AC 5 ms
5,172 KB
testcase_09 AC 6 ms
4,944 KB
testcase_10 AC 46 ms
5,820 KB
testcase_11 AC 5 ms
5,156 KB
testcase_12 AC 5 ms
5,232 KB
testcase_13 AC 5 ms
5,076 KB
testcase_14 AC 5 ms
5,040 KB
testcase_15 AC 5 ms
4,956 KB
testcase_16 AC 5 ms
5,016 KB
testcase_17 AC 5 ms
5,016 KB
testcase_18 AC 57 ms
5,308 KB
testcase_19 AC 37 ms
5,788 KB
testcase_20 AC 35 ms
5,652 KB
testcase_21 AC 38 ms
5,624 KB
testcase_22 AC 37 ms
5,608 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use strict;
use warnings;

my $num = <STDIN>;
my @w = split(' ', <STDIN>);

my $sum = eval join('+', @w);

my %p = (0 => 0);
my %n = %p;

my $ans = 'impossible';

if($sum%2 == 0){
  my $half = $sum/2;
  my $hs;

  LOOP: for my $i (@w){
    for my $j (keys %p){
      $hs = $j + $i;
      if($hs == $half){
        $ans = 'possible';
        last LOOP;
      }elsif($hs < $half){
        $n{$hs} = 1;
      }
    }
    %p = %n;
  }
}

print $ans;
0