結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-10-23 15:48:22 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 704 bytes |
コンパイル時間 | 2,578 ms |
コンパイル使用メモリ | 74,824 KB |
実行使用メモリ | 42,012 KB |
最終ジャッジ日時 | 2024-11-24 01:55:57 |
合計ジャッジ時間 | 6,396 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 4 |
ソースコード
/* 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 { // your code goes here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int w[] = new int[n]; 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"); } }