結果

問題 No.54 Happy Hallowe'en
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2024-01-01 22:25:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 943 bytes
コンパイル時間 5,211 ms
コンパイル使用メモリ 320,252 KB
実行使用メモリ 52,332 KB
最終ジャッジ日時 2024-01-01 22:25:41
合計ジャッジ時間 6,864 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,212 KB
testcase_01 AC 32 ms
52,212 KB
testcase_02 AC 31 ms
52,212 KB
testcase_03 AC 32 ms
52,212 KB
testcase_04 AC 36 ms
52,244 KB
testcase_05 AC 38 ms
52,260 KB
testcase_06 AC 46 ms
52,276 KB
testcase_07 AC 45 ms
52,296 KB
testcase_08 AC 47 ms
52,312 KB
testcase_09 AC 49 ms
52,332 KB
testcase_10 AC 32 ms
52,212 KB
testcase_11 AC 31 ms
52,212 KB
testcase_12 AC 48 ms
52,332 KB
testcase_13 AC 47 ms
52,332 KB
testcase_14 AC 32 ms
52,212 KB
testcase_15 AC 32 ms
52,212 KB
testcase_16 AC 34 ms
52,212 KB
testcase_17 AC 33 ms
52,212 KB
testcase_18 AC 32 ms
52,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>


using namespace std;
using namespace atcoder;
#define rep(i,m,n,k) for (int i = (int)(m); i < (int)(n); i += (int)(k))
#define rrep(i,m,n,k) for (int i = (int)(m); i > (int)(n); i += (int)(k))
#define ll long long
#define list(T,A,N) vector<T> A(N);for(int i=0;i<(int)(N);i++){cin >> A[i];}


int main(){
    
    int N;
    cin >> N;
    vector<tuple<int,int,int>> VT(N);
    int v,t;
    rep(i,0,N,1){
        cin >> v >> t;
        VT[i] = {v+t,v,t};
    }
    sort(VT.begin(),VT.end());
    bitset<20000> S;
    bitset<20000> I;
    I.set(0,1);
    vector<bitset<20000>> msk(20000);
    msk[0].set(0,1);
    rep(i,0,19999,1){
        msk[i+1] = I|(msk[i]<<1);
    }
    S.set(0,1);
    for(auto [_,vv,tt]:VT){
        S |= (msk[tt-1]&S)<<vv;
    }
    int ans = 0;
    rep(i,0,20000,1){
        if (S.test(i)){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;

}
0