結果

問題 No.4 おもりと天秤
ユーザー cwwcww
提出日時 2017-09-23 13:31:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 815 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 198,772 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-26 15:31:05
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 5 ms
7,168 KB
testcase_02 AC 5 ms
7,168 KB
testcase_03 AC 4 ms
7,296 KB
testcase_04 AC 5 ms
7,168 KB
testcase_05 AC 5 ms
7,168 KB
testcase_06 AC 4 ms
7,168 KB
testcase_07 AC 5 ms
7,296 KB
testcase_08 AC 5 ms
7,296 KB
testcase_09 AC 6 ms
7,168 KB
testcase_10 AC 5 ms
7,040 KB
testcase_11 AC 4 ms
7,168 KB
testcase_12 AC 4 ms
7,168 KB
testcase_13 AC 5 ms
7,168 KB
testcase_14 AC 5 ms
7,168 KB
testcase_15 AC 4 ms
7,168 KB
testcase_16 WA -
testcase_17 AC 5 ms
7,168 KB
testcase_18 AC 6 ms
7,296 KB
testcase_19 AC 5 ms
7,168 KB
testcase_20 AC 5 ms
7,296 KB
testcase_21 AC 6 ms
7,168 KB
testcase_22 AC 6 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0