Submission #60538406
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define int long long
#define f(i,j,n) for(int i=j;i<=n;i++)
#define updmax(a,b) a=max(a,b)
#define updmin(a,b) a=min(a,b)
#define XQZ
using namespace std;
int dp[2][510][50010];
int n,X,K;
struct acc{
int p,u,c;
}w[511];
void gs(){
cin>>n>>X>>K;
f(i,1,n)cin>>w[i].p>>w[i].u>>w[i].c;
sort(w+1,w+1+n,[&](acc a,acc b){
return a.c<b.c;
});
int p=0;
int ans=0;
f(i,1,n){
if(i!=1&&w[i].c!=w[i-1].c){
f(j,0,X)updmax(dp[p][i-1][j],dp[p^1][i-1][j]),dp[p^1][i-1][j]=0;
p^=1;
}
f(j,0,X){
dp[p][i][j]=dp[p][i-1][j];
dp[p^1][i][j]=dp[p^1][i-1][j];
if(j>=w[i].p){
updmax(dp[p][i][j],dp[p][i-1][j-w[i].p]+w[i].u);
updmax(dp[p][i][j],dp[p^1][i-1][j-w[i].p]+w[i].u+K);
}
updmax(ans,dp[p][i][j]);
updmax(ans,dp[p^1][i][j]);
}
}
cout<<ans<<endl;
}
signed main(){
#ifndef XQZ
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
#endif
#ifdef NXD
int t=0;cin>>t;while(t--)
#endif
gs();
return 0;
}
Submission Info
Submission Time |
|
Task |
F - Diversity |
User |
xiangqizhen |
Language |
C++ 17 (Clang 16.0.6) |
Score |
525 |
Code Size |
1013 Byte |
Status |
AC |
Exec Time |
167 ms |
Memory |
394228 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
525 / 525 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt, 01_test_46.txt, 01_test_47.txt, 01_test_48.txt, 01_test_49.txt, 01_test_50.txt, 01_test_51.txt, 01_test_52.txt, 01_test_53.txt, 01_test_54.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
3560 KB |
00_sample_01.txt |
AC |
1 ms |
3580 KB |
00_sample_02.txt |
AC |
1 ms |
3760 KB |
01_test_00.txt |
AC |
1 ms |
3636 KB |
01_test_01.txt |
AC |
1 ms |
3628 KB |
01_test_02.txt |
AC |
4 ms |
10448 KB |
01_test_03.txt |
AC |
27 ms |
63608 KB |
01_test_04.txt |
AC |
5 ms |
11200 KB |
01_test_05.txt |
AC |
126 ms |
300420 KB |
01_test_06.txt |
AC |
92 ms |
181428 KB |
01_test_07.txt |
AC |
92 ms |
180764 KB |
01_test_08.txt |
AC |
56 ms |
110968 KB |
01_test_09.txt |
AC |
121 ms |
230040 KB |
01_test_10.txt |
AC |
62 ms |
122388 KB |
01_test_11.txt |
AC |
166 ms |
361144 KB |
01_test_12.txt |
AC |
161 ms |
340232 KB |
01_test_13.txt |
AC |
9 ms |
20640 KB |
01_test_14.txt |
AC |
3 ms |
8216 KB |
01_test_15.txt |
AC |
5 ms |
11388 KB |
01_test_16.txt |
AC |
123 ms |
297020 KB |
01_test_17.txt |
AC |
124 ms |
297080 KB |
01_test_18.txt |
AC |
123 ms |
297036 KB |
01_test_19.txt |
AC |
123 ms |
295148 KB |
01_test_20.txt |
AC |
124 ms |
295248 KB |
01_test_21.txt |
AC |
122 ms |
295180 KB |
01_test_22.txt |
AC |
167 ms |
375476 KB |
01_test_23.txt |
AC |
161 ms |
224596 KB |
01_test_24.txt |
AC |
4 ms |
9860 KB |
01_test_25.txt |
AC |
158 ms |
388000 KB |
01_test_26.txt |
AC |
167 ms |
394228 KB |
01_test_27.txt |
AC |
160 ms |
379284 KB |
01_test_28.txt |
AC |
92 ms |
187268 KB |
01_test_29.txt |
AC |
161 ms |
332172 KB |
01_test_30.txt |
AC |
145 ms |
294856 KB |
01_test_31.txt |
AC |
157 ms |
387440 KB |
01_test_32.txt |
AC |
165 ms |
374696 KB |
01_test_33.txt |
AC |
155 ms |
334788 KB |
01_test_34.txt |
AC |
86 ms |
173748 KB |
01_test_35.txt |
AC |
153 ms |
324252 KB |
01_test_36.txt |
AC |
152 ms |
324412 KB |
01_test_37.txt |
AC |
97 ms |
207684 KB |
01_test_38.txt |
AC |
98 ms |
207668 KB |
01_test_39.txt |
AC |
118 ms |
246056 KB |
01_test_40.txt |
AC |
119 ms |
246044 KB |
01_test_41.txt |
AC |
144 ms |
313420 KB |
01_test_42.txt |
AC |
143 ms |
313548 KB |
01_test_43.txt |
AC |
160 ms |
344288 KB |
01_test_44.txt |
AC |
160 ms |
343960 KB |
01_test_45.txt |
AC |
119 ms |
255032 KB |
01_test_46.txt |
AC |
118 ms |
255168 KB |
01_test_47.txt |
AC |
150 ms |
312704 KB |
01_test_48.txt |
AC |
150 ms |
312540 KB |
01_test_49.txt |
AC |
10 ms |
24128 KB |
01_test_50.txt |
AC |
10 ms |
24252 KB |
01_test_51.txt |
AC |
5 ms |
13952 KB |
01_test_52.txt |
AC |
6 ms |
14084 KB |
01_test_53.txt |
AC |
62 ms |
132860 KB |
01_test_54.txt |
AC |
62 ms |
132864 KB |