QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#357517 | #3056. Live Programming | Kevin5307 | WA | 44ms | 127276kb | C++20 | 1.3kb | 2024-03-18 22:12:41 | 2024-03-18 22:12:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,t;
ll f[4004],p[4004],l[4004];
ll dp[4004][4004];
deque<pair<ll,ll>> dq[4004];
long double slope(pair<ll,ll> a,pair<ll,ll> b)
{
return 1.0L*(b.first-a.first)/(b.second-a.second);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>t;
for(int i=1;i<=n;i++)
cin>>l[i]>>p[i]>>f[i];
for(int i=1;i<=n;i++)
for(int j=1;j<n;j++)
if(f[j]>f[j+1])
{
swap(f[j],f[j+1]);
swap(p[j],p[j+1]);
swap(l[j],l[j+1]);
}
for(int i=0;i<=n;i++)
for(int j=0;j<=t;j++)
dp[i][j]=-1e14;
dp[0][0]=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=t;j++) if(dp[i-1][j]>=-1e13)
{
ll vy=dp[i-1][j]-f[i-1]*f[i-1];
ll vx=f[i-1]+f[i-1];
while(dq[j].size()>1&&slope(dq[j][dq[j].size()-2],dq[j].back())<slope(dq[j].back(),pair<ll,ll>(vy,vx)))
dq[j].pop_back();
dq[j].emplace_back(vy,vx);
}
for(int j=0;j<=t-l[i];j++) if(dq[j].size())
{
while(dq[j].size()>1&&slope(dq[j][0],dq[j][1])>-f[i])
dq[j].pop_front();
dp[i][j+l[i]]=dq[j][0].first+dq[j][0].second*f[i]-f[i]*f[i]+p[i];
}
dp[i][l[i]]=max(dp[i][l[i]],p[i]);
}
ll ans=0;
for(int i=0;i<=n;i++)
for(int j=0;j<=t;j++)
ans=max(ans,dp[i][j]);
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 6252kb
input:
2 10 10 200 1 10 100 100
output:
200
result:
ok single line: '200'
Test #2:
score: 0
Accepted
time: 2ms
memory: 6256kb
input:
3 15 5 100 1 5 100 2 5 100 4
output:
295
result:
ok single line: '295'
Test #3:
score: 0
Accepted
time: 2ms
memory: 6492kb
input:
3 10 5 200 200 5 200 201 5 300 1
output:
399
result:
ok single line: '399'
Test #4:
score: 0
Accepted
time: 2ms
memory: 6300kb
input:
3 20 5 100 200 5 100 201 5 300 1
output:
300
result:
ok single line: '300'
Test #5:
score: 0
Accepted
time: 2ms
memory: 6304kb
input:
5 61 14 49 7 31 46 4 30 55 5 52 99 1 34 70 3
output:
103
result:
ok single line: '103'
Test #6:
score: 0
Accepted
time: 2ms
memory: 8192kb
input:
42 16 16 72073499 4632 1 18467047 9046 14 31273517 3525 3 43577541 4655 1 31950136 410 3 35007694 5797 9 49328891 4854 2 74367508 7864 7 51170926 6563 4 77856895 784 1 78297498 3393 16 77127326 8501 16 71424103 6731 4 61491251 9925 3 76313409 4018 4 59712678 2624 5 43021655 9439 10 14064673 6791 4 1...
output:
448259665
result:
ok single line: '448259665'
Test #7:
score: 0
Accepted
time: 3ms
memory: 10508kb
input:
64 17 13 23916157 888 1 22334161 8106 5 64756275 9683 11 30753510 5644 7 94891777 3978 12 55980188 427 6 6540494 6728 3 98108147 3243 4 97266872 5008 2 67036662 869 7 10060360 9008 16 54165933 2716 14 2836966 6200 11 95955330 8715 8 78063765 6641 1 70178421 9095 17 88168595 861 5 32864912 497 11 176...
output:
579504064
result:
ok single line: '579504064'
Test #8:
score: 0
Accepted
time: 2ms
memory: 8404kb
input:
46 16 14 81598337 3552 11 88196612 3612 6 19284768 8025 15 94746496 640 10 38944210 9658 9 83707521 8401 12 74473205 2793 7 95611173 5014 7 32689034 6079 4 85474165 3828 4 32475219 3333 10 86932984 8988 10 84739464 202 5 33650562 3173 16 83135736 2238 3 42763804 861 7 33345463 3510 4 80045035 8420 1...
output:
485842176
result:
ok single line: '485842176'
Test #9:
score: 0
Accepted
time: 2ms
memory: 8452kb
input:
83 18 5 26109671 5229 9 5869134 8624 17 68285176 5334 17 25966106 9778 10 99012646 6103 8 36881819 350 6 68916818 4268 5 12416787 2059 12 33926135 8430 13 53053393 28 16 37917483 3939 13 69640803 8622 8 58733914 5754 12 45812390 1939 11 28539882 6776 3 22976416 1198 13 57192555 4131 7 49897524 2425 ...
output:
531995609
result:
ok single line: '531995609'
Test #10:
score: 0
Accepted
time: 0ms
memory: 6372kb
input:
27 15 5 77446548 5081 10 44320822 7153 6 84527050 9258 7 21481696 5028 13 30193873 4597 15 60993463 505 9 50705149 1269 14 60112392 9949 15 37189654 5763 11 28439956 8197 5 41786770 6315 1 11584464 1052 14 70218645 3449 5 60451409 8298 10 71696550 2703 5 26454699 8541 5 70627710 9987 14 66906649 826...
output:
239424098
result:
ok single line: '239424098'
Test #11:
score: 0
Accepted
time: 0ms
memory: 10392kb
input:
79 16 12 37122590 8434 16 36047757 3933 6 92059912 1419 13 88871914 7686 14 57455124 4481 11 48623936 7290 4 88768842 4194 8 7423394 2638 16 46806688 8799 10 63145519 6442 4 17430787 3219 5 40769755 9071 13 26919811 5465 9 91749043 7660 13 16216543 9099 6 81862394 474 8 39107921 7219 15 28979566 800...
output:
519730524
result:
ok single line: '519730524'
Test #12:
score: 0
Accepted
time: 0ms
memory: 8368kb
input:
48 12 2 4646818 666 3 88260305 8335 8 59021859 6524 6 35794089 3133 7 94155606 4497 4 81614809 2095 9 64147226 4085 7 69078705 6681 12 17700055 5282 3 24315032 4590 2 69975114 818 10 59495399 1905 4 65190135 6105 5 21551800 946 3 27596797 2663 6 10757603 7745 5 258958 8215 1 74731249 8172 7 46639577...
output:
520273468
result:
ok single line: '520273468'
Test #13:
score: 0
Accepted
time: 2ms
memory: 8412kb
input:
75 13 7 94331647 6193 13 80404992 7 8 66203187 199 2 85139526 3649 7 20011372 5657 10 26593330 6819 2 84322268 9858 5 26098094 3039 10 65390456 9232 1 54845879 1406 3 50242479 5693 11 47678893 1254 11 72624601 6191 2 95744917 2705 9 64216241 1633 10 3391876 9531 10 57800618 196 2 69415076 9220 1 800...
output:
659466995
result:
ok single line: '659466995'
Test #14:
score: 0
Accepted
time: 0ms
memory: 10372kb
input:
76 14 7 35720038 6189 7 95147273 7448 2 66389185 2399 14 91945044 9925 9 95763495 7400 9 59066766 8511 8 58533280 4785 8 98657793 6785 3 48637340 6118 2 44011086 565 6 37267686 9429 7 64214239 3355 3 29549884 9361 11 86549276 9162 12 42712794 2273 5 40439365 4775 14 1504459 4199 10 62357906 6461 11 ...
output:
395962320
result:
ok single line: '395962320'
Test #15:
score: 0
Accepted
time: 0ms
memory: 8212kb
input:
59 13 4 26703215 7701 6 64093157 9927 8 1190305 6862 3 27259567 1263 5 87320488 4726 5 8514068 5928 12 41959224 9674 13 47118837 2277 13 71316772 34 3 64744216 5802 10 39623039 8418 11 33619746 2729 1 17573922 1329 2 60255675 9802 5 9231818 6421 4 59481829 3360 13 12077561 7829 4 7146913 7203 8 5915...
output:
443826668
result:
ok single line: '443826668'
Test #16:
score: 0
Accepted
time: 13ms
memory: 74132kb
input:
2171 66 37 62090351 8571 29 49788882 7156 9 74127468 6410 3 14494975 9234 18 98069986 7486 14 69153326 5436 66 89664863 361 25 92260063 3807 9 94370348 890 59 10712232 9445 55 33302118 7245 12 20133542 8125 51 90598109 9513 46 47205380 9746 15 91687141 258 19 45001071 7916 37 13141333 439 3 95698563...
output:
3069887407
result:
ok single line: '3069887407'
Test #17:
score: 0
Accepted
time: 0ms
memory: 14492kb
input:
230 95 59 98077375 2637 55 24308109 398 68 94671272 5440 83 18283437 5567 90 19837292 8317 22 92988658 1356 65 7437553 8707 20 79844602 258 7 22700323 9207 21 4888168 8575 64 45370766 9677 88 76403031 3237 10 76978021 2849 19 28902853 3092 39 89957851 1108 85 22553300 8929 85 88067846 1384 70 319421...
output:
1111820191
result:
ok single line: '1111820191'
Test #18:
score: 0
Accepted
time: 0ms
memory: 29064kb
input:
680 85 53 89158567 3459 71 80387994 350 51 87597680 7952 68 26528530 6147 39 86996350 7180 71 49213920 381 18 11870254 7512 30 54350516 3510 9 18866093 3534 18 15151887 7214 33 23154858 2296 79 26738236 6590 28 75440983 6973 22 70905626 1783 13 29502014 9158 36 24405664 2363 83 70656488 7946 70 7530...
output:
1755969453
result:
ok single line: '1755969453'
Test #19:
score: 0
Accepted
time: 30ms
memory: 96472kb
input:
2869 100 81 13249001 7904 8 8756771 9537 80 98675312 4569 96 87009805 5013 45 17182915 5574 44 85245277 549 88 14335813 6949 87 9136510 2857 58 74684646 4408 48 74073403 5791 68 13863136 3435 9 16690209 2826 40 82002010 5920 29 24345507 2931 51 15640753 5452 15 46175164 6872 18 41456782 5369 97 2642...
output:
3612877304
result:
ok single line: '3612877304'
Test #20:
score: 0
Accepted
time: 11ms
memory: 68148kb
input:
1955 52 39 71385387 4311 23 21513691 2327 35 15641077 9998 14 69816765 8790 51 18808298 7362 34 56057220 3233 50 71455725 4916 47 671915 9044 36 80338862 218 51 22054578 4566 18 7721117 9705 10 12261373 6305 32 85783232 4190 41 35706003 1013 24 21277413 789 46 55952583 4861 7 80914240 7824 10 314640...
output:
3064637911
result:
ok single line: '3064637911'
Test #21:
score: 0
Accepted
time: 2ms
memory: 8472kb
input:
96 70 56 77970493 1909 64 39378164 3088 22 91698700 834 32 37401854 9962 65 71462640 5539 69 41275507 8733 16 65143324 4601 48 41667300 3203 17 13641272 1269 15 26547760 3769 30 86175412 6459 1 95393882 6693 16 62213284 2789 44 39446616 7424 63 94515470 1285 37 29350609 2742 63 85825043 3115 55 9182...
output:
1033436938
result:
ok single line: '1033436938'
Test #22:
score: 0
Accepted
time: 22ms
memory: 96568kb
input:
2858 93 49 85188876 6051 40 64409859 5696 75 3692752 8859 64 78831517 2414 85 33194652 5549 46 77606999 5093 16 66094028 5302 11 62602985 2921 29 9968604 6847 66 71134643 8824 72 50212492 5516 34 79009854 5792 20 8543950 1161 28 72850152 7977 11 37032176 1423 77 31061542 6246 57 47694101 6312 38 190...
output:
3498452387
result:
ok single line: '3498452387'
Test #23:
score: 0
Accepted
time: 24ms
memory: 98660kb
input:
2887 75 59 73832369 3834 7 56079343 1107 25 35821237 5531 47 4026696 1141 47 68177147 4084 33 47826502 6863 46 63257569 335 48 52734840 7261 18 55574594 399 23 93530549 4302 7 39937588 4834 25 7535855 2150 41 1144238 3150 25 18650633 5055 44 49364185 2416 17 90441152 942 48 64970375 5794 65 92247042...
output:
3547995405
result:
ok single line: '3547995405'
Test #24:
score: 0
Accepted
time: 44ms
memory: 127276kb
input:
3846 85 66 52931980 6742 39 10324323 5341 4 47853964 3820 73 94591413 9028 2 80055836 6197 71 83167938 44 64 19171670 21 69 98537507 4267 8 98452293 7599 35 29390251 6405 2 27662236 2443 38 42072268 2793 53 87721516 3046 54 15868002 3477 65 15236455 2335 55 61884292 1815 75 8233820 7914 51 42439747 ...
output:
4233082423
result:
ok single line: '4233082423'
Test #25:
score: 0
Accepted
time: 36ms
memory: 113048kb
input:
3446 63 13 57597409 3609 15 28641508 3281 15 46943561 5520 7 79748221 7072 39 47554436 5735 16 82720331 8308 44 7036101 4911 20 20901597 1268 58 72169673 3540 19 97819394 1762 15 74333907 539 18 94401479 5833 18 21744610 4422 35 13241835 5998 45 67176386 8535 3 27194993 4657 19 39067997 5570 34 4787...
output:
3422180138
result:
ok single line: '3422180138'
Test #26:
score: 0
Accepted
time: 16ms
memory: 80072kb
input:
2326 62 38 49771898 9218 28 39727440 2211 5 13968890 2003 5 12960371 7344 10 82118439 3010 20 78067627 3873 51 64313016 47 12 53604214 5959 20 61283029 3432 56 12541788 9716 1 90324851 5705 3 65144872 2734 47 8937317 3024 51 75887615 8114 22 84097958 8433 24 28776454 6672 56 8758218 3599 3 73408846 ...
output:
3265808392
result:
ok single line: '3265808392'
Test #27:
score: 0
Accepted
time: 2ms
memory: 8752kb
input:
89 61 28 44769574 3523 49 96052572 7907 17 26348104 8097 24 87599119 4953 37 61089048 3778 33 11778317 7437 55 11875902 3806 21 4011189 4501 15 92008699 2883 18 59283489 4117 23 28641551 1297 49 55102423 6247 26 4166947 6768 23 52415278 2529 2 68384978 2785 58 69732023 4939 28 18267049 3729 45 10630...
output:
767257782
result:
ok single line: '767257782'
Test #28:
score: -100
Wrong Answer
time: 2ms
memory: 8444kb
input:
57 96 96 99999168 2134 18 18749808 2133 5 5208280 2132 96 99999072 2131 5 5208295 2135 19 19791483 2135 10 10416590 2132 19 19791483 2132 10 10416580 2133 9 9374922 2132 15 15624870 2132 12 12499884 2133 9 9374922 2132 14 14583198 2130 8 8333256 2133 17 17708152 2134 12 12499872 2135 9 9374922 2133 ...
output:
99999244
result:
wrong answer 1st lines differ - expected: '99999258', found: '99999244'