結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2020-01-02 16:13:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 420 bytes |
コンパイル時間 | 1,832 ms |
コンパイル使用メモリ | 171,520 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 18:10:24 |
合計ジャッジ時間 | 2,440 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n; scanf("%d",&n); vector<int> w(n); rep(i,n) scanf("%d",&w[i]); int sum=accumulate(w.begin(),w.end(),0); if(sum%2!=0) return puts("impossible"),0; vector<bool> dp(5e3+1); dp[0]=true; rep(i,n) for(int a=sum/2;a>=w[i];a--) if(dp[a-w[i]]) dp[a]=true; puts(dp[sum/2]?"possible":"impossible"); return 0; }