結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2020-07-05 19:16:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 1,777 ms |
コンパイル使用メモリ | 172,276 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 18:24:52 |
合計ジャッジ時間 | 2,826 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using Graph=vector<vector<pair<int,int>>>; using pp=pair<int,pair<int,int>>; #define MAX 200003 #define MOD 1000000007 #define INF 1000000000 int main(){ int N; cin>>N; vector<int> W(N); int sum=0; for(int i=0;i<N;i++){ cin>>W[i]; sum+=W[i]; } vector<bool> dp(sum+1,false); dp.at(0)=true; for(int i=0;i<N;i++){ for(int j=sum;j-W[i]>=0;j--){ dp[j]=dp[j]|dp[j-W[i]]; } } if(sum%2==0){ if(dp[sum/2]==true){ cout<<"possible"<<endl; }else{ cout<<"impossible"<<endl; } }else{ cout<<"impossible"<<endl; } }