結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
r_dream0
|
| 提出日時 | 2017-03-01 21:19:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 307 ms / 5,000 ms |
| コード長 | 801 bytes |
| コンパイル時間 | 787 ms |
| コンパイル使用メモリ | 78,540 KB |
| 実行使用メモリ | 393,756 KB |
| 最終ジャッジ日時 | 2024-06-12 22:44:46 |
| 合計ジャッジ時間 | 3,226 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int dp[10001][10001];
int main() {
vector<pair<int, pair<int,int>>> input;
int N;
cin >> N;
input.resize(N);
for(int i = 0; i < input.size(); i++) {
cin >> input[i].second.second >> input[i].second.first;
input[i].first = input[i].second.second + input[i].second.first;
}
sort(input.begin(), input.end());
dp[0][0] = 1;
int ans = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j <= 10000; j++) {
if(dp[i][j]) {
int next = j + input[i].second.second;
if(j < input[i].second.first) {
ans = max(ans, next);
if(next <= 10000) {
dp[i + 1][next] = 1;
}
}
dp[i + 1][j] = 1;
}
}
}
cout << ans << endl;
}
r_dream0