UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#172518#2085. 大鱼吃小鱼sfsadfsa10032ms1280kbC++11689b2023-07-01 23:08:542023-07-01 23:08:56

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const long long INF = 1e18;

int n, k; 
void solve() {
	cin >> n >> k; 
	vector<int> a(n), p(n), t(n);
	for (int i = 0; i < n; ++i) cin >> a[i] >> p[i] >> t[i]; 
	vector<ll> f(k + 1010, INF); 
	f[0] = 0;
	for (int j = 0; j <= k; ++j) {
		for (int i = 0; i < n; ++i) {
			if (j >= a[i]) {
				f[j + p[i]] = min(f[j + p[i]], f[j] + t[i]);
			}
		}
	}
	ll res = INF;
	for (int i = k; i <= k + 1000; ++i) {
		res = min(res, f[i]);
	}
	cout << res << "\n";
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
	int T; cin >> T;
	while (T --) {
		solve();
	}
	return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 16
Accepted
time: 0ms
memory: 1204kb

input:

0

output:


result:

ok 0 lines

Test #2:

score: 16
Accepted
time: 0ms
memory: 1256kb

input:

10
1 1000
0 584 999000148
1 1000
0 991 999017298
1 1000
0 330 999016787
1 1000
0 621 999022712
1 100...

output:

1998000296
1998034596
3996067148
1998045424
1998034376
1998025506
8991093249
8991005166
3996089388
7...

result:

ok 10 lines

Test #3:

score: 16
Accepted
time: 0ms
memory: 1268kb

input:

10
1000 1
0 276 999030363
821 731 999023252
728 87 999002538
219 844 999019007
547 406 999015920
518...

output:

999023017
999007574
999001538
999018463
999022885
999022263
999004957
999002816
999005880
999000195

result:

ok 10 lines

Test #4:

score: 16
Accepted
time: 14ms
memory: 1280kb

input:

10
1000 1000
0 53 999025977
489 960 999025977
569 623 999025977
815 421 999025977
802 721 999025977
...

output:

1998051954
1998063952
1998064664
1998064828
1998065088
1998002482
1998000688
1998020122
1998044352
1...

result:

ok 10 lines

Test #5:

score: 16
Accepted
time: 0ms
memory: 1252kb

input:

10
4 10
0 8 999030050
5 5 999030532
0 4 999031300
3 7 999021130
4 10
1 2 999023823
1 7 999013335
9 7...

output:

1998051180
1998035742
1998023793
1998046501
1998035164
1998027003
999009284
2997057901
3996032963
19...

result:

ok 10 lines

Test #6:

score: 16
Accepted
time: 18ms
memory: 1276kb

input:

10
1000 1000
781 282 999028314
411 818 999011167
421 460 999006007
0 407 999029366
905 32 999008657
...

output:

1998029526
1998009525
1998006994
1998025402
1998000379
1998030527
1998010010
1998007100
1998001078
1...

result:

ok 10 lines