結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
FpmpAmpm
|
| 提出日時 | 2016-10-23 15:39:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 701 bytes |
| コンパイル時間 | 3,883 ms |
| コンパイル使用メモリ | 74,712 KB |
| 実行使用メモリ | 42,140 KB |
| 最終ジャッジ日時 | 2024-11-24 01:55:42 |
| 合計ジャッジ時間 | 6,619 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 16 |
ソースコード
/* 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[100];
// 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) {
sum2 += w[n-1-i];
} else {
sum1 += w[n-1-i];
}
}
System.out.println((sum1 == sum2) ? "possible":"impossible");
}
}
FpmpAmpm