ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198719 | #2452. B | wosile | 100 | 1668ms | 333804kb | C++11 | 1.5kb | 2023-11-30 09:04:28 | 2023-11-30 12:11:29 |
answer
// Problem: A. B
// Contest: undefined - NOI2024省选训练赛 40
// URL: http://119.28.3.174/contest/955/problem/2452
// Memory Limit: 512 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int lowbit(int x){
return (x&(-x));
}
int read(){
int x=0,c=getchar(),f=1;
while(c<'0' || c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0' && c<='9'){
x=(x<<3)+(x<<1)+c-'0';
c=getchar();
}
return f==1?x:-x;
}
void write(ll x){
if(x>9)write(x/10);
putchar(x%10+48);
}
int T,Tc;
int n;
ll f[85][85][6405];
ll x[85],y[85],z[85];
int main(){
Tc=read();
T=read();
while(T--){
n=read();
for(int i=1;i<=n;i++){
x[i]=read();
y[i]=read();
z[i]=read();
}
for(int i=0;i<=n+1;i++)for(int j=0;j<=n;j++)for(int k=0;k<=n*n;k++)f[i][j][k]=0xc0c0c0c0c0c0c0c0;
f[n+1][0][0]=0;
for(int i=n;i>=1;i--)for(int j=0;j<=n-i+1;j++)for(int k=0;k<=n*j;k++){
if(j>0 && k>=i)f[i][j][k]=max(f[i][j][k],f[i+1][j-1][k-i]+x[i]);
f[i][j][k]=max(f[i][j][k],f[i+1][j][k]+j*y[i]);
f[i][j][k]=max(f[i][j][k],f[i+1][j][k]+(k-j*i)*z[i]);
// printf("f[%d][%d][%d]=%lld\n",i,j,k,f[i][j][k]);
}
ll ans=0;
for(int i=0;i<=n;i++)for(int j=0;j<=n*n;j++)ans=max(ans,f[1][i][j]);
write(ans);
putchar(10);
}
return 0;
}
//quod erat demonstrandum
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1144kb
input:
1 10 1 0 3 0 1 521 11 595 1 417455 17317 50844 1 70192 6508565 1106210 1 17 25 15 1 18693432 6637271...
output:
0 521 417455 70192 17 18693432 9976 5651 1 9184
result:
ok 10 lines
Test #2:
score: 5
Accepted
time: 0ms
memory: 1172kb
input:
2 10 2 883 300 1298 56 8734 9326 2 424871171 194336280 811712274 55219032 78665177 9082197 2 1011072...
output:
1354 866931306 43903260 752 7 13236079 55 1601604 738346267 1268
result:
ok 10 lines
Test #3:
score: 5
Accepted
time: 0ms
memory: 1748kb
input:
3 10 10 158046 841932 1256173 764231 195526 6775904 6802298 6722619 69663 205872 225656 103128 10111...
output:
370423877 2820 227132 168 17586678490 40474811441 2139068539 41839 9637258 56193459
result:
ok 10 lines
Test #4:
score: 5
Accepted
time: 0ms
memory: 1748kb
input:
4 10 10 0 0 0 0 0 0 0 2 4 0 7 2 9 0 2 0 0 0 0 6 9 1 0 0 0 0 0 3 9 6 10 1549761 34003809 569024446 83...
output:
202 39132937521 8947031 69 28990985 562 15321357 90846 56301000056 31543001
result:
ok 10 lines
Test #5:
score: 5
Accepted
time: 0ms
memory: 1744kb
input:
5 10 10 3140 18315 27746 2941 45397 85348 238 72892 878 4924 8833 69479 4117 7978 13129 19924 89781 ...
output:
5825340 117496 307663 439403024 21301 3697509 222 2317277004 121 5010616
result:
ok 10 lines
Test #6:
score: 5
Accepted
time: 36ms
memory: 63524kb
input:
6 25 20 7462001 0 0 22348000 0 0 751769 0 0 198036 0 0 4863163 0 0 1840546 0 0 75038768 0 0 92270896...
output:
597398806 15 41 5120854220 366920 33023779 12 10 5064857697 4849521923 3651 368 20867 4947543 299531...
result:
ok 25 lines
Test #7:
score: 5
Accepted
time: 37ms
memory: 63520kb
input:
7 25 20 6 0 0 63 12 0 54 0 0 19 0 0 85 6 0 0 3 0 49 0 0 7 0 0 68 86 0 0 0 0 8 0 0 69 6 0 0 6 0 7 61 ...
output:
2117 7350 4572 54231297 72492825 6413 533326232 2983 63249654 345 708154424 4883 58141837 51744 4655...
result:
ok 25 lines
Test #8:
score: 5
Accepted
time: 34ms
memory: 63524kb
input:
8 25 20 46513 0 0 6253 63 0 77863 0 0 91225 0 0 3617 81 0 7346 3 0 7291 0 0 94938 4 0 4355 93 0 4621...
output:
581570 40390 37656819 5401267 307027 3463573 265 36126624 53576798 477310 4994325 253590568 60288325...
result:
ok 25 lines
Test #9:
score: 5
Accepted
time: 50ms
memory: 63524kb
input:
9 25 20 92945909 6691160 0 96720852 280897269 0 352257151 36544435 0 298101282 654916992 0 65917979 ...
output:
30786974329 247916 261 434679 48072973 4783 1604459552 4760 2023727 2970967 2344396 24367579935 2679...
result:
ok 25 lines
Test #10:
score: 5
Accepted
time: 32ms
memory: 63524kb
input:
10 25 20 723 121 0 60 874 0 9 729 0 464 88 0 27 217 0 308 86 0 119 22 0 0 35 0 82 377 0 8 43 0 80 6 ...
output:
36671 36440973662 2044237456 239 41262391857 228 197 303667227 4843 2533448676 248 22508334 236721 2...
result:
ok 25 lines
Test #11:
score: 5
Accepted
time: 36ms
memory: 63524kb
input:
11 25 20 705653 81928 0 140959 18722 0 95113 78108 0 35133 36503 0 88419 343409 0 247339 331677 0 68...
output:
24931234 532367626 215 211223651 3322 181172 39089333916 480499498 39547 3300414290 391252 254966 32...
result:
ok 25 lines
Test #12:
score: 5
Accepted
time: 177ms
memory: 333804kb
input:
12 25 20 78397049 2637194 0 44802760 18444905 0 33107269 792996829 0 880561270 171991508 0 957744407...
output:
35394181636 1486254778 498298 3636084 32785 20549459208 4088179197 3878242847 3205 29672772 29165011...
result:
ok 25 lines
Test #13:
score: 5
Accepted
time: 189ms
memory: 333800kb
input:
13 25 20 29 8312 0 444 307 0 45 698 0 7640 5152 0 2292 858 0 698 5197 0 334 7807 0 7623 1067 0 63 33...
output:
456029 2887 35649394384 309 21975 430338378 3242121226 34565338497 52272016282 396019484 17734046566...
result:
ok 25 lines
Test #14:
score: 5
Accepted
time: 278ms
memory: 333804kb
input:
14 25 20 697809 903083 0 18436 8465719 0 455133 45918 0 80171 4380073 0 2817219 88985 0 2221980 2606...
output:
419114700 329676359 397655795 219 32808298 3381109471 269 167 358543 20614639 38301 3464991 52454742...
result:
ok 25 lines
Test #15:
score: 5
Accepted
time: 61ms
memory: 63524kb
input:
15 25 20 3 0 4 0 6 2 0 0 5 0 0 0 9 0 0 0 0 0 0 8 0 0 0 0 0 4 6 0 0 2 0 5 9 0 2 6 0 0 3 0 0 0 0 0 6 0...
output:
2600 339340 185410311561 154575658694 126699663333 24601818340 1880736 3715 2832912904 3089 2229 168...
result:
ok 25 lines
Test #16:
score: 5
Accepted
time: 56ms
memory: 63520kb
input:
16 25 20 94236 5558 66838 78677 13431 56506 54168 876 95216 396 2073 9264 8979 97417 838 8111 3592 7...
output:
44832591 24893 1951 2165 15517630429 35653782421 21911224239 239251 5792217737 334640378001 13323124...
result:
ok 25 lines
Test #17:
score: 5
Accepted
time: 52ms
memory: 63524kb
input:
17 25 20 38358167 8720134 92898945 702923 6723166 951852 51931279 1664762 89442443 9661230 8760543 3...
output:
38252825171 244518 3634 36115971843 35626320 145244 1792413 25344781224 1341 216331886 37402 2392212...
result:
ok 25 lines
Test #18:
score: 5
Accepted
time: 268ms
memory: 333800kb
input:
18 25 20 29 74 0 0 9 14 7 19 5 24 95 4 90 76 2 0 1 27 0 0 4 96 45 3 47 4 9 3 9 71 1 27 3 9 28 8 71 6...
output:
13093 15162 29914 34921975 86400517 25166164745 36716 298917925476 39883207618 17452070 8576942800 1...
result:
ok 25 lines
Test #19:
score: 5
Accepted
time: 170ms
memory: 333804kb
input:
19 25 20 20492 63749 3286 24644 1095 616 6467 4054 6506 2736 9046 5769 28408 4905 776 5147 154 129 6...
output:
9410268 19123 4666380 2549971 2605899496 22187841686 2601 2622042567 2507 2537133 359737 24384053054...
result:
ok 25 lines
Test #20:
score: 5
Accepted
time: 192ms
memory: 333800kb
input:
20 25 20 42717191 40935557 10935392 110410 19836885 11366338 49174556 4497680 2842944 612553686 1544...
output:
105017560917 291680 1790 19634 18576695703 1309020 143587 179459627 9025598 202570462165 1629679316 ...
result:
ok 25 lines
Extra Test:
score: 0
Extra Test Passed