結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
piniky
|
| 提出日時 | 2016-10-04 12:59:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 846 bytes |
| コンパイル時間 | 1,377 ms |
| コンパイル使用メモリ | 161,924 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 10:01:36 |
| 合計ジャッジ時間 | 2,264 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
| 外部呼び出し有り |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:15: warning: ignoring return value of ‘int system(const char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
48 | system("PAUSE");
| ~~~~~~^~~~~~~~~
ソースコード
#include "bits/stdc++.h"
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;
void solve() {
#ifdef _WIN32
istream &cin = ifstream("input.txt");
#endif
int n, sum = 0;
cin >> n;
VI w(n);
VI dp(n * 100 + 1);
rep(i, n) {
cin >> w[i];
sum += w[i];
}
dp[0] = 1;
rep(i, n) {
for (int j = n * 100; j >= 0; j--) {
if (j - w[i] >= 0 && dp[j - w[i]] == 1) dp[j] = 1;
}
}
if (sum % 2 == 1) cout << "impossible" << endl;
else if (dp[sum / 2] == 1) cout << "possible" << endl;
else cout << "impossible" << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
system("PAUSE");
return 0;
}
piniky