結果
| 問題 | No.54 Happy Hallowe'en |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-07 03:24:50 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,088 bytes |
| 記録 | |
| コンパイル時間 | 1,312 ms |
| コンパイル使用メモリ | 132,560 KB |
| 最終ジャッジ日時 | 2025-01-21 07:50:48 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 7 |
ソースコード
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>
#include <random>
using namespace std;
int dp[10001];
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
vector <pair<int, int>> v;
int n, a, b;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a >> b;
v.push_back(make_pair(a, b));
}
sort(v.begin(), v.end());
for (int i = 0; i <= n; i++)
{
dp[i] = -1e9;
}
dp[0] = 0;
for (int i = 1; i <= n; i++)
{
int a = v[i - 1].first;
int b = v[i - 1].second;
for (int j = 0; j < i; j++)
{
if (dp[j] < b)
{
dp[i] = max(dp[i], dp[j] + a);
}
}
}
int res = 0;
for (int i = 0; i <= n; i++)
{
res = max(res, dp[i]);
}
cout << res << '\n';
return 0;
}