結果
問題 |
No.54 Happy Hallowe'en
|
ユーザー |
|
提出日時 | 2014-10-28 02:21:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 3,052 ms |
コンパイル使用メモリ | 67,160 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-30 13:50:03 |
合計ジャッジ時間 | 2,546 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int INF = 1 << 28; const int dp_size = 10010; int N; vector<pair<int, int>> house; int dp[dp_size]; int main(){ cin >> N; for(int i=0;i<N;i++){ int V, T; cin >> V >> T; house.push_back(make_pair(T, V)); } sort(house.begin(), house.end()); for(int i=0;i<dp_size;i++)dp[i] = -INF; dp[0] = 0; for(int i=0;i<N;i++){ int T = house[i].first; int V = house[i].second; for(int t=0;t<T;t++)if(dp[t] != -INF){ int nt = min(t + V, 10000); dp[nt] = max(dp[nt], dp[t] + V); } } int res = -INF; for(int t=0;t<=10000;t++)res = max(res, dp[t]); cout << res << endl; return 0; }