結果
問題 | No.4 おもりと天秤 |
ユーザー | youthfuldays072 |
提出日時 | 2018-05-04 10:40:09 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 2,203 ms |
コンパイル使用メモリ | 72,156 KB |
実行使用メモリ | 58,256 KB |
最終ジャッジ日時 | 2023-09-10 09:30:51 |
合計ジャッジ時間 | 5,887 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
56,688 KB |
testcase_01 | AC | 120 ms
55,828 KB |
testcase_02 | AC | 120 ms
56,084 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 120 ms
56,136 KB |
testcase_07 | WA | - |
testcase_08 | AC | 128 ms
56,180 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 123 ms
55,772 KB |
testcase_12 | AC | 121 ms
55,516 KB |
testcase_13 | AC | 120 ms
55,832 KB |
testcase_14 | AC | 120 ms
56,140 KB |
testcase_15 | AC | 119 ms
55,856 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 133 ms
56,116 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args) { Main main=new Main(); main.run(); } void run() { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] w=new int[n]; for (int i = 0; i < w.length; i++) { w[i]=sc.nextInt(); } Arrays.sort(w); int[] dp= new int[10001]; int sum=0; dp[0]=1; for(int i=0;i<n;i++) { sum+=w[i]; dp[i+w[i]]=dp[i]; } if(sum%2==1 || dp[sum/2]==0) { System.out.println("impossible"); }else { System.out.println("possible"); } } }