結果

問題 No.4 おもりと天秤
ユーザー sugarrrsugarrr
提出日時 2018-01-04 14:09:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 67,556 KB
実行使用メモリ 5,772 KB
最終ジャッジ日時 2023-08-24 18:54:12
合計ジャッジ時間 2,098 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    int n;cin>>n;
    int w[n+1];for(int i=1;i<=n;i++)cin>>w[i];
    bool dp[n+1][22001];
    for(int i=0;i<=22000;i++)dp[0][i]=false;
    dp[0][11000]=true;
    for(int i=1;i<=n;i++)for(int j=0;j<=22000;j++){
        dp[i][j]=(dp[i-1][j+w[i]]||dp[i-1][j-w[i]]);
    }
     if(dp[n][11000]==true)printf("possible");
    else printf("impposible");
    return 0;
}
0