結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-04-08 00:11:07 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 85 ms / 5,000 ms | 
| コード長 | 675 bytes | 
| コンパイル時間 | 2,139 ms | 
| コンパイル使用メモリ | 194,372 KB | 
| 最終ジャッジ日時 | 2025-01-09 14:58:07 | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#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';
}
            
            
            
        