結果
問題 |
No.54 Happy Hallowe'en
|
ユーザー |
|
提出日時 | 2025-06-27 16:45:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 2,206 ms |
コンパイル使用メモリ | 203,488 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-27 16:45:08 |
合計ジャッジ時間 | 3,545 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<pair<int,int>> VT(N); for(auto &[v,t] : VT) cin >> v >> t; sort(VT.begin(),VT.end(),[&](auto &a,auto &b){return a.first+a.second<b.first+b.second;}); bitset<20001> dp; dp.set(0); bitset<20001> d; for(auto [v,t] : VT){ d.reset(); for(int i=0; i<t; i++) d.set(i); dp |= (dp&d)<<v; } for(int i=20000; i>=0; i--) if(dp.test(i)){cout << i << endl; break;} }