結果

問題 No.4 おもりと天秤
ユーザー ngtkanangtkana
提出日時 2020-04-08 00:11:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 201,304 KB
実行使用メモリ 6,340 KB
最終ジャッジ日時 2023-09-22 18:51:38
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,156 KB
testcase_01 AC 8 ms
6,152 KB
testcase_02 AC 16 ms
6,304 KB
testcase_03 AC 12 ms
6,092 KB
testcase_04 AC 16 ms
6,100 KB
testcase_05 AC 72 ms
6,148 KB
testcase_06 AC 5 ms
6,260 KB
testcase_07 AC 70 ms
6,264 KB
testcase_08 AC 71 ms
6,132 KB
testcase_09 AC 71 ms
6,244 KB
testcase_10 AC 71 ms
6,236 KB
testcase_11 AC 10 ms
6,144 KB
testcase_12 AC 8 ms
6,340 KB
testcase_13 AC 7 ms
6,236 KB
testcase_14 AC 8 ms
6,148 KB
testcase_15 AC 7 ms
6,092 KB
testcase_16 AC 11 ms
6,232 KB
testcase_17 AC 10 ms
6,108 KB
testcase_18 AC 72 ms
6,100 KB
testcase_19 AC 72 ms
6,204 KB
testcase_20 AC 71 ms
6,140 KB
testcase_21 AC 71 ms
6,148 KB
testcase_22 AC 71 ms
6,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint max=100'000;
    std::vector<lint>dp(2*max+1,false);
    dp.at(max)=true;
    lint n;std::cin>>n;
    while(n--){
        lint x;std::cin>>x;
        std::vector<lint>swp(2*max+1,false);
        for(lint i=0;i<=2*max;i++){
            if(x<=i)swp.at(i-x)|=dp.at(i);
            if(i<=2*max-x)swp.at(i+x)|=dp.at(i);
        }
        swp.swap(dp);
    }
    std::cout<<(dp.at(max)?"possible":"impossible")<<'\n';
}
0