結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
cww
|
| 提出日時 | 2017-09-23 13:31:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 815 bytes |
| コンパイル時間 | 2,461 ms |
| コンパイル使用メモリ | 198,364 KB |
| 最終ジャッジ日時 | 2025-01-05 03:00:30 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
// 配るDP編
int main()
{
int N;
cin >> N;
vector<int> vc( N );
for( auto &x : vc )
{
cin >> x;
}
int total = accumulate( ALL( vc ), 0 );
vector<vector<int>> dp( 100 + 1, vector<int>( 10000 + 1 ) );
dp[ 0 ][ 0 ] = 1;
for( int i = 0; i < N; i++ )
{
for( int j = 0; j <= total; j++ )
{
dp[ i + 1 ][ j ] |= dp[ i ][ j ];
dp[ i + 1 ][ j + vc[ i - 1 ] ] |= dp[ i ][ j ];
}
}
cout << ( dp[ N - 1 ][ total / 2 ] && total % 2 == 0 ? "possible" : "impossible" ) << endl;
return 0;
}
cww