結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
atn112323
|
| 提出日時 | 2017-01-03 16:12:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 5,000 ms |
| コード長 | 560 bytes |
| コンパイル時間 | 588 ms |
| コンパイル使用メモリ | 60,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 06:21:05 |
| 合計ジャッジ時間 | 1,662 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <algorithm>
#include <iostream>
using namespace std;
const int MAXN = 10000;
const int MAXV = 20000;
int N;
int V[MAXN], T[MAXN];
pair<int, int> P[MAXN];
bool dp[MAXV + 1];
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> V[i] >> T[i];
P[i] = make_pair(V[i] + T[i], i);
}
sort(P, P + N);
dp[0] = true;
int ans = 0;
for (int i = 0; i < N; i++) {
int j = P[i].second;
for (int k = T[j] - 1; k >= 0; k--) {
if (dp[k]) {
dp[k + V[j]] = true;
ans = max(ans, k + V[j]);
}
}
}
cout << ans << endl;
return 0;
}
atn112323