結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2021-02-10 22:04:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 168,704 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2024-07-08 09:33:28 |
合計ジャッジ時間 | 7,973 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 17 |
ソースコード
#include <bits/stdc++.h> #include <iostream> #include<math.h> using namespace std; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } vector<int>vec; int avg; int N; bool dfs(int index, int now) { int n = vec[index]; int add_case = now + n; if (now == avg) return true; if (index < N) { return (dfs(index+1, add_case) || dfs(index+1, now)); } else { return false; } } int main() { cin >> N; vec.resize(N); int sum = 0; for (int i=0; i<N; i++) { cin >> vec.at(i); sum += vec[i]; } if (sum % 2 != 0) { cout << "impossible" << endl; } else { avg = sum/2; if (dfs(0, 0)) { cout << "possible" << endl; } else { cout << "impossible" << endl; } } return 0; }