結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2015-04-21 23:47:52 |
言語 | Perl (5.40.0) |
結果 |
AC
|
実行時間 | 162 ms / 5,000 ms |
コード長 | 868 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 09:10:53 |
合計ジャッジ時間 | 2,917 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
#!/usr/bin/evn perl use strict; use warnings; my $n = <>; my $str = <>; chomp $str; my @array = split / /, $str; my @first; my @second; my $res = 0; for(my $h = 0; $h < $n; $h++) { $res += $array[$h]; } $res /= 2; if($res != int $res) { print "impossible\n"; exit; } #配列の初期化 for(my $i = 0; $i < 100**2; $i++) { $first[$i] = 0; $second[$i] = 0; } $first[0] = 1; #入力した数字だけ調べる for(my $i = 0; $i < $n; $i++) { #0..100で1があるところを調べる for(my $j = 0; $j < 100**2; $j++) { #もし1があった時 if($first[$j] == 1) { $second[$array[$i] + $j] = 1; } } #firstとsecondを合わせて、firstに格納 for(my $k = 0; $k < 100**2; $k++) { if(($first[$k] == 1)or($second[$k] == 1)) { $first[$k] = 1; } } } if($first[$res] == 1) { print "possible\n"; } else { print "impossible\n"; } exit;