結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-10-23 15:43:13 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 702 bytes |
コンパイル時間 | 2,372 ms |
コンパイル使用メモリ | 83,740 KB |
実行使用メモリ | 52,504 KB |
最終ジャッジ日時 | 2024-11-24 01:55:49 |
合計ジャッジ時間 | 6,197 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 10 |
ソースコード
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { int w[] = new int[1000]; // your code goes here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int j = 0; j < n; j++) { w[j] = sc.nextInt(); } sc.close(); Arrays.sort(w); int sum1 = w[n-1]; int sum2 = 0; for (int i = 1; i < n;i++) { if (sum1 < sum2) { sum1 += w[n-1-i]; } else { sum2 += w[n-1-i]; } } System.out.println((sum1 == sum2) ? "possible":"impossible"); } }