結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2017-04-22 10:25:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 869 bytes |
コンパイル時間 | 802 ms |
コンパイル使用メモリ | 74,656 KB |
実行使用メモリ | 10,144 KB |
最終ジャッジ日時 | 2024-07-21 16:02:44 |
合計ジャッジ時間 | 7,045 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 17 |
ソースコード
#include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> using namespace std; typedef long long ll; //typedef pair<int, int> P; int w[101],P[101]; int N,sum,res1,res2,flag=0; void solve() { for (int i = 0; i < N; i++) { if (P[i]) { res1 += w[i]; } else { res2 += w[i]; } } if (res1 == res2) { flag = 1; } } void Set(int x) { if (x >= N) { res1 = res2 = 0; solve(); return; } for (int i = 0; i < 2; i++) { P[x] = i; Set(x + 1); } } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> w[i]; sum += w[i]; } if (sum % 2 != 0) { cout << "impossible" << endl; return 0; } Set(0); if (flag) { cout << "possible" << endl; } else cout << "impossible" << endl; return 0; }