Submission #70801376


Source Code Expand

#include<bits/stdc++.h>
//#include<iostream>
//#include<cmath>
//#include<string>
//#include<string.h>
//#include<math.h>
//#include<float.h>
using namespace std;
#define int long long 
int n;
int w[200010],h[200010],a[200010];
int ans,sum;
void solve(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> w[i] >> h[i] >> a[i];
		ans += a[i];
		sum += w[i];
	}
	int hh = sum / 2;
	vector<int> f(hh + 1,-1e18); 
	f[0] = 0;
	for(int i = 1;i <= n;i++){
		int t = h[i] - a[i];
		for(int j = hh;j >= w[i];j--)
			if(f[j - w[i]] != -1e9)
				f[j] = max(f[j],f[j - w[i]] + t);
	}
	int mx = 0;
	for(int i = 0;i <= hh;i++){
		mx = max(mx,f[i]);
	//	cout << f[i] << " "; 
	}
	cout << ans + mx;
}
signed main(){
	int T = 1;
//	cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

Submission Info

Submission Time
Task D - Robot Customize
User Eirck
Language C++23 (GCC 15.2.0)
Score 400
Code Size 804 Byte
Status AC
Exec Time 44 ms
Memory 4320 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 54
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3436 KiB
00_sample_01.txt AC 1 ms 3576 KiB
00_sample_02.txt AC 1 ms 3584 KiB
00_sample_03.txt AC 1 ms 3684 KiB
01_random_03.txt AC 22 ms 3784 KiB
01_random_04.txt AC 22 ms 3724 KiB
01_random_05.txt AC 23 ms 3780 KiB
01_random_06.txt AC 23 ms 3796 KiB
01_random_07.txt AC 23 ms 3728 KiB
01_random_08.txt AC 23 ms 3728 KiB
01_random_09.txt AC 23 ms 3796 KiB
01_random_10.txt AC 23 ms 3808 KiB
01_random_11.txt AC 23 ms 3808 KiB
01_random_12.txt AC 15 ms 3852 KiB
01_random_13.txt AC 6 ms 3696 KiB
01_random_14.txt AC 5 ms 3600 KiB
01_random_15.txt AC 9 ms 3684 KiB
01_random_16.txt AC 4 ms 3600 KiB
01_random_17.txt AC 22 ms 3780 KiB
01_random_18.txt AC 23 ms 3808 KiB
01_random_19.txt AC 23 ms 3808 KiB
01_random_20.txt AC 22 ms 3724 KiB
01_random_21.txt AC 23 ms 3804 KiB
01_random_22.txt AC 5 ms 3688 KiB
01_random_23.txt AC 1 ms 3616 KiB
01_random_24.txt AC 1 ms 3572 KiB
01_random_25.txt AC 23 ms 3632 KiB
01_random_26.txt AC 24 ms 3852 KiB
01_random_27.txt AC 23 ms 3796 KiB
01_random_28.txt AC 23 ms 3848 KiB
01_random_29.txt AC 23 ms 3708 KiB
01_random_30.txt AC 24 ms 3796 KiB
01_random_31.txt AC 17 ms 3768 KiB
01_random_32.txt AC 9 ms 3700 KiB
01_random_33.txt AC 1 ms 3608 KiB
01_random_34.txt AC 1 ms 3440 KiB
01_random_35.txt AC 23 ms 3724 KiB
01_random_36.txt AC 22 ms 3852 KiB
01_random_37.txt AC 23 ms 3808 KiB
01_random_38.txt AC 22 ms 3728 KiB
01_random_39.txt AC 23 ms 3800 KiB
01_random_40.txt AC 22 ms 3780 KiB
01_random_41.txt AC 23 ms 3808 KiB
01_random_42.txt AC 23 ms 3800 KiB
01_random_43.txt AC 9 ms 3652 KiB
01_random_44.txt AC 19 ms 3848 KiB
01_random_45.txt AC 16 ms 3852 KiB
01_random_46.txt AC 2 ms 3548 KiB
01_random_47.txt AC 7 ms 3604 KiB
01_random_48.txt AC 44 ms 4320 KiB
01_random_49.txt AC 44 ms 4308 KiB
01_random_50.txt AC 44 ms 4308 KiB
01_random_51.txt AC 1 ms 3768 KiB
01_random_52.txt AC 8 ms 3800 KiB