結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
nak3
|
| 提出日時 | 2017-03-11 17:57:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 610 bytes |
| コンパイル時間 | 1,347 ms |
| コンパイル使用メモリ | 159,156 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 12:33:48 |
| 合計ジャッジ時間 | 2,205 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
int main()
{
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll sum = accumulate(a, a+n, 0);
if (sum%2!=0) {
cout << "impossible" << "\n";
return 0;
}
ll h = sum/2;
for (int all = 0; all < (1<<n); all++) {
int subsum = 0;
for (int i = 0; i < n; i++) {
if (all & (1<<i)) {
subsum += a[i];
}
}
if (subsum==h) {
cout << "possible" << "\n";
return 0;
}
}
cout << "impossible" << "\n";
return 0;
}
nak3