結果
問題 | No.54 Happy Hallowe'en |
ユーザー |
![]() |
提出日時 | 2015-05-30 05:15:12 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 453 ms |
コンパイル使用メモリ | 60,124 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 17:13:08 |
合計ジャッジ時間 | 1,520 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include<iostream>#include<utility>#include<algorithm>using namespace std;typedef pair<int,int> P;P p[10010];bool dp[20010] = {true};int main(){int n;cin >> n;for (int i = 0; i < n; i++){cin >> p[i].second >> p[i].first;p[i].first += p[i].second;}sort(p, p + n);for (int i = 0; i < n; i++){for (int j = p[i].first-p[i].second - 1; j >= 0; j--){dp[j + p[i].second] |= dp[j];}}int res = 0;for (int i = 0; i < 20010; i++){if (dp[i])res = i;}cout << res << endl;}