結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-18 09:50:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 552 bytes |
| コンパイル時間 | 906 ms |
| コンパイル使用メモリ | 54,256 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-10-04 13:25:53 |
| 合計ジャッジ時間 | 7,168 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 1 -- * 4 |
ソースコード
#include <iostream>
#include <cstring>
using namespace std;
#define N 100
int n;
int w[N];
int hw;
int dfs(int no, int tw)
{
tw += w[no];
if ( tw == hw ) {
return 1;
}
if ( tw > hw ) {
return -1;
}
for ( int i = no + 1; i < n; i++ ) {
int x = dfs(i, tw);
if ( x == 1 ) {
return x;
}
}
return 0;
}
int main()
{
cin >> n;
for ( int i = 0; i < n; i++ ) {
cin >> w[i];
hw += w[i];
}
if ( hw % 2 == 0 && (hw /= 2, dfs(0, 0) == 1) ) {
cout << "possible" << endl;
}
else {
cout << "impossible" << endl;
}
return 0;
}