結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-10-30 23:06:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 862 bytes |
| コンパイル時間 | 838 ms |
| コンパイル使用メモリ | 66,852 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 14:35:44 |
| 合計ジャッジ時間 | 2,193 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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=T-1;t>=0;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;
}