Submission #24973879
Source Code Expand
#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = 1000000007; int dp[5020][5020]; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<pair<int, P>>p; for (int i = 0; i < N; i++) { int D, C, S; cin >> D >> C >> S; p.push_back({ D, {C, S} }); } sort(p.begin(), p.end()); for (int j = 0; j <= 5010; j++) { for (int i = 0; i < N; i++) { if (j + p[i].second.first <= p[i].first) { dp[i + 1][j + p[i].second.first] = max(dp[i + 1][j + p[i].second.first], dp[i][j] + p[i].second.second); } dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } int ans = 0; for (int i = 0; i < 5010; i++) { ans = max(ans, dp[N][i]); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | 011 - Gravy Jobs(★6) |
User | Example |
Language | C++ (GCC 9.2.1) |
Score | 6 |
Code Size | 852 Byte |
Status | AC |
Exec Time | 447 ms |
Memory | 199836 KiB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | Subtask3 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 2 / 2 | 2 / 2 | 2 / 2 | ||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_0_123.txt, 00_sample_1_123.txt, 00_sample_2_123.txt, 00_sample_3__23.txt, 00_sample_4___3.txt |
Subtask1 | 00_sample_0_123.txt, 00_sample_1_123.txt, 00_sample_2_123.txt, 01_random_0_123.txt, 01_random_1_123.txt, 01_random_2_123.txt, 01_random_3_123.txt |
Subtask2 | 00_sample_0_123.txt, 00_sample_1_123.txt, 00_sample_2_123.txt, 00_sample_3__23.txt, 01_random_0_123.txt, 01_random_1_123.txt, 01_random_2_123.txt, 01_random_3_123.txt, 02_random_0__23.txt, 02_random_1__23.txt, 02_random_2__23.txt, 02_random_3__23.txt, 03_maxima_0__23.txt, 03_maxima_1__23.txt, 03_maxima_2__23.txt, 03_maxima_3__23.txt |
Subtask3 | 00_sample_0_123.txt, 00_sample_1_123.txt, 00_sample_2_123.txt, 00_sample_3__23.txt, 00_sample_4___3.txt, 01_random_0_123.txt, 01_random_1_123.txt, 01_random_2_123.txt, 01_random_3_123.txt, 02_random_0__23.txt, 02_random_1__23.txt, 02_random_2__23.txt, 02_random_3__23.txt, 03_maxima_0__23.txt, 03_maxima_1__23.txt, 03_maxima_2__23.txt, 03_maxima_3__23.txt, 04_random_0__3.txt, 04_random_1__3.txt, 04_random_2__3.txt, 04_random_3__3.txt, 05_maxima_0__3.txt, 05_maxima_1__3.txt, 05_maxima_2__3.txt, 05_maxima_3__3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_0_123.txt | AC | 8 ms | 3604 KiB |
00_sample_1_123.txt | AC | 2 ms | 3712 KiB |
00_sample_2_123.txt | AC | 2 ms | 3756 KiB |
00_sample_3__23.txt | AC | 4 ms | 4384 KiB |
00_sample_4___3.txt | AC | 5 ms | 4804 KiB |
01_random_0_123.txt | AC | 2 ms | 3860 KiB |
01_random_1_123.txt | AC | 3 ms | 3836 KiB |
01_random_2_123.txt | AC | 2 ms | 3644 KiB |
01_random_3_123.txt | AC | 3 ms | 3776 KiB |
02_random_0__23.txt | AC | 4 ms | 4068 KiB |
02_random_1__23.txt | AC | 4 ms | 4280 KiB |
02_random_2__23.txt | AC | 4 ms | 4248 KiB |
02_random_3__23.txt | AC | 3 ms | 4132 KiB |
03_maxima_0__23.txt | AC | 5 ms | 4392 KiB |
03_maxima_1__23.txt | AC | 4 ms | 4292 KiB |
03_maxima_2__23.txt | AC | 3 ms | 4396 KiB |
03_maxima_3__23.txt | AC | 3 ms | 4384 KiB |
04_random_0__3.txt | AC | 294 ms | 137156 KiB |
04_random_1__3.txt | AC | 133 ms | 75084 KiB |
04_random_2__3.txt | AC | 21 ms | 13556 KiB |
04_random_3__3.txt | AC | 26 ms | 20652 KiB |
05_maxima_0__3.txt | AC | 447 ms | 199836 KiB |
05_maxima_1__3.txt | AC | 402 ms | 199824 KiB |
05_maxima_2__3.txt | AC | 413 ms | 199768 KiB |
05_maxima_3__3.txt | AC | 421 ms | 199728 KiB |