結果

問題 No.4 おもりと天秤
コンテスト
ユーザー id-ord
提出日時 2026-01-10 13:54:01
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 304 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,730 ms
コンパイル使用メモリ 168,024 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-10 13:54:05
合計ジャッジ時間 2,533 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
int main(){
	int N;std::cin>>N;
	std::vector<int> W(N);for(auto& w:W)std::cin>>w;
	int sum=0;
	for(auto& w:W)sum+=w;
	std::vector<bool> X(2*sum+1);
	X[0]=1;
	for(auto& w:W)for(int i=2*sum;i>=2*w;i--)X[i]=X[i-2*w]|X[i];
	std::cout<<(X[sum]?"possible":"impossible");
}
0