結果

問題 No.54 Happy Hallowe'en
ユーザー snrnsidysnrnsidy
提出日時 2021-05-07 03:24:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,088 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 135,516 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 19:00:56
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,356 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 43 ms
4,352 KB
testcase_07 WA -
testcase_08 AC 105 ms
4,352 KB
testcase_09 AC 149 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 129 ms
4,352 KB
testcase_13 AC 101 ms
4,348 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0