結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2014-10-26 15:51:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 677 ms |
コンパイル使用メモリ | 81,904 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-06-26 09:02:16 |
合計ジャッジ時間 | 1,712 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include<iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #define _USE_MATH_DEFINES #include <math.h> #include<string> #include<vector> #include<cmath> #include<stack> #include<queue> #include<sstream> #include<algorithm> #include<map> #include<complex> #include<ctime> #include<set> using namespace std; #define li long long int #define rep(i,to) for(li i=0;i<((li)(to));i++) #define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v,n) memset(v,(li)n,sizeof(v)) #define bit(n) (1ll<<(li)(n)) #define mp(a,b) make_pair(a,b) #define rin rep(i,n) #define EPS 1e-10 #define ETOL 1e-8 #define MOD 1000000007 #define F first #define S second #define p2(a,b) cout<<a<<"\t"<<b<<endl #define p3(a,b,c) cout<<a<<"\t"<<b<<"\t"<<c<<endl li dp[110][11111]; li w[110]; int main(){ li n; li sum=0; cin>>n; rin{cin>>w[i]; sum+=w[i];} rep(i,n+1){ rep(j,10001){ dp[i][j]=0; } } dp[0][0]=1; rep(i,n+1){ rep(j,10001){ if(dp[i][j])dp[i+1][j]=dp[i+1][j+w[i]]=1; } } if(sum%2>0 || dp[n][sum/2]==0)puts("impossible"); else puts("possible"); return 0; }