結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-15 14:08:07 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 5,000 ms |
| + 199µs | |
| コード長 | 1,017 bytes |
| 記録 | |
| コンパイル時間 | 8,905 ms |
| コンパイル使用メモリ | 385,496 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-10-15 14:08:19 |
| 合計ジャッジ時間 | 10,765 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;
// using mint=modint998244353;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,s=0;
cin>>N;
vi w(N);
rep(i,0,N)cin>>w[i],s+=w[i];
if(s%2==1){
cout<<"impossible\n";
return 0;
}
int t=s/2;
vector<bool>dp(t+1,false);
dp[0]=true;
rep(i,0,N){
rrep(j,0,t+1){
if(j-w[i]>=0&&dp[j-w[i]])dp[j]=true;
}
}
if(dp[t])cout<<"possible\n";
else cout<<"impossible\n";
}
C