結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-24 01:37:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 928 bytes |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 75,236 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 04:09:22 |
| 合計ジャッジ時間 | 1,463 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 5 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#define rep(i, n) for(int (i)=0; (i)<(n); ++(i))
using namespace std;
int main()
{
int n;
cin >> n;
int w[100];
map<int, bool> m;
m[0] = true;
int sum = 0;
rep(i, n) {
cin >> w[i];
sum += w[i];
}
if(sum % 2 == 1) {
cout << "impossible" << endl;
return 0;
}
rep(i, n) {
map<int, bool> mm;
for(map<int, bool>::iterator itr = m.begin(); itr != m.end(); ++itr) {
if(i + itr->first == sum / 2) {
cout << "possible" << endl;
return 0;
}
mm[i + itr->first] = true;
}
for(map<int, bool>::iterator itr = mm.begin(); itr != mm.end(); ++itr) {
m[itr->first] = true;
}
}
cout << "impossible" << endl;
return 0;
}