結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2020-06-08 05:53:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 85,656 KB |
最終ジャッジ日時 | 2025-01-11 00:06:03 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <set> #include <string> #include <map> #include <numeric> using namespace std; typedef long long int ll; bool dp[10001]; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); int sum=0; for(int i=0;i<n;i++){ cin >> a[i]; sum+=a[i]; } dp[0]=1; for(int j=0;j<n;j++){ for(int i=10000;i>=0;i--){ if(dp[i]){ dp[i+a[j]]=1; } } } if(sum%2==0&&dp[sum/2]){ printf("possible\n"); } else{ printf("impossible\n"); } }