結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2020-06-24 23:50:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 582 ms / 5,000 ms |
コード長 | 1,011 bytes |
コンパイル時間 | 927 ms |
コンパイル使用メモリ | 89,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 20:28:30 |
合計ジャッジ時間 | 4,586 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long ll; typedef pair<int, int> P; int N; int v_[10000], t_[10000]; int v[10000], t[10000]; P p[10000]; int ans; bool ok[10001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; for(int i = 0; i < N; i++){ cin >> v_[i] >> t_[i]; p[i] = P(v_[i]+t_[i], i); } sort(p, p+N); for(int i = 0; i < N; i++){ int idx = p[i].second; v[i] = v_[idx]; t[i] = t_[idx]; } ok[0] = true; for(int i = 0; i < N; i++){ vector<int> u; for(int j = 0; j <= 10000; j++){ if(ok[j]){ u.push_back(j); if(j < t[i]) u.push_back(j+v[i]); } } for(int j : u) { ok[j] = true; ans = max(ans, j); } } cout << ans << endl; }