QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317602 | #7122. Overtaking | Random_Code# | 10 | 2ms | 13140kb | C++17 | 2.5kb | 2024-01-29 09:25:49 | 2024-04-28 08:34:35 |
Judging History
answer
//ANMHLIJKTJIY!
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#include "overtaking.h"
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define F first
#define S second
#define ll long long
#define N 1010
#define M 1000010
using namespace std;
ll n,m,pn,len,s[N],arr[N][N],res[N][N],ord[N],curt;
pair<ll,ll> t[N];
vector<ll> allv[N];
bool cmp(ll x,ll y)
{
return arr[x][curt]<arr[y][curt];
}
void init(int _l,int _n,vector<ll> _t,vector<int> _w,int _x,int _m,vector<int> _s)
{
ll i,j,k;
len=_l,n=_n,m=_m;
for(i=0;i<m;i++)
{
s[i]=_s[i];
}
for(i=0;i<n;i++)
{
t[i].S=_t[i];
t[i].F=_w[i];
}
pn=_x;
sort(t,t+n);
reverse(t,t+n);
for(i=0;i<n;i++)
{
if(t[i].F<=pn)
{
n=i;
break;
}
}
for(i=0;i<n;i++)
{
arr[i][0]=t[i].S;
}
for(i=1;i<m;i++)
{
curt=i-1;
for(j=0;j<n;j++)
{
ord[j]=j;
}
sort(ord,ord+n,cmp);
ll mx=0;
for(j=k=0;j<n;j++)
{
while(k<j&&arr[ord[k]][i-1]<arr[ord[j]][i-1])
{
mx=max(mx,arr[ord[k++]][i]);
}
arr[ord[j]][i]=max(arr[ord[j]][i-1]+t[ord[j]].F*(s[i]-s[i-1]),mx);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
allv[i].push_back(arr[j][i]);
}
sort(allv[i].begin(),allv[i].end());
}
for(i=m-1;i>=0;i--)
{
for(j=0;j<allv[i].size();j++)
{
if(j==0)
{
res[i][j]=allv[i][j]+(s[m-1]-s[i])*t[n].F;
continue;
}
ll l=i,r=m-1;
while(l<r)
{
ll mid=(l+r)>>1;
if(allv[mid][j-1]<allv[i][j]+(s[mid]-s[i])*t[n].F)
{
l=mid+1;
}
else
{
r=mid;
}
}
if(l==m-1)
{
res[i][j]=max(allv[m-1][j-1],allv[i][j]+(s[m-1]-s[i])*t[n].F);
}
else
{
ll p=lower_bound(allv[l].begin(),allv[l].end(),allv[l][j-1])-allv[l].begin();
res[i][j]=res[l][p];
}
}
}
return;
}
ll arrival_time(ll x)
{
ll num=lower_bound(allv[0].begin(),allv[0].end(),x)-allv[0].begin(),l=0,r=m-1;
if(num==0)
{
return x+s[m-1]*pn;
}
while(l<r)
{
ll mid=(l+r)>>1;
if(allv[mid][num-1]<x+s[mid]*pn)
{
l=mid+1;
}
else
{
r=mid;
}
}
if(l==m-1)
{
return max(allv[m-1][num-1],x+s[m-1]*pn);
}
ll p=lower_bound(allv[l].begin(),allv[l].end(),allv[l][num-1])-allv[l].begin();
return res[l][p];
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8112kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 2500 1 78 100 1000 100000 80 0 38 51 89 92 105 117 119 122 126 142 179 259 355 385 410 419 443 483 496 551 671 691 698 709 762 778 818 860 888 897 909 930 938 946 951 955 995 1045 1091 1164 1187 1215 1243 1264 1301 1363 1409 1416 1448 1504 1518 1535 1555 1562 1597 16...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 286560 228960 266640 220320 104080 222800 187280 246000 232480 155840 160960 222800 133520 176400 175680 194960 247360 107360 128400 262480 155280 247360 224400 220320 281200 250640 138640 262480 171760 259920 289520 156720 243520 175040 104080 294400 128400 13080...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '299664', found: '286560'
Subtask #2:
score: 10
Accepted
Test #12:
score: 10
Accepted
time: 1ms
memory: 5908kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 2000000 100 100 2 1000 566035866 424023571 564031634 266012245 266012901 566037245 106005324 106003684 266012594 424028440 424019007 106005224 564034079 424024371 424024546 566039191 424016814 424029581 82000890 754044052 566036512 424018510 424017279 424019925 42401...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 768035150 768029581 1144044184 308008207 768029581 768029581 956039191 768029581 956041170 768029581 768029581 308008207 956039191 308008207 768029581 768029891 1144044184 418008550 768029581 468009953 308008207 1144044184 768035150 768029581 468010817 768029581 6...
result:
ok
Test #13:
score: 0
Accepted
time: 2ms
memory: 10020kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 10000000 400 1011 2 1000 173387969125 200337983261 77920310897 77652037350 182097978669 118267907350 174157972712 57062023028 118267909308 107247901578 174157973485 146027951049 53742020545 118267912197 174167974422 207927989121 137207921414 143227933063 77992040344 ...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 128387906425 192867977136 218447987834 162297954325 192867978986 34992000977 147437922857 192867979350 67182020640 56912011273 63862013824 162297954325 43302006404 92682052132 120767905711 218447987834 98882054684 138667917161 63862014242 117367898279 210667984418...
result:
ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 12092kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 10000 800 1522451 2 1000 102691961165 356949771920 280550316262 154390571762 439415828789 473733275923 465056851706 434971147676 473185083883 407141567243 446269133331 245826204010 132720147100 266857422544 300276587668 200566213815 304647607947 8994460481 3661139508...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 480548847785 422389308676 261050720686 480548847785 24218980889 488958822294 290598660610 61394536039 454767827473 117916481772 160323101016 454767828952 109098515326 222192213960 467092876761 319997647668 369154287532 146931915291 501350951422 319997648312 242189...
result:
ok
Test #15:
score: 0
Accepted
time: 2ms
memory: 12556kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 1000 10000 2 1000 148512009450 164605927216 127484617319 27096740437 161301908126 227401559568 220855479544 152976736303 161069395645 159703894172 122292102200 189557102648 122405102528 39895753566 164605425801 106641054484 84900003806 152618881097 73504974935...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 237134063601 77319966760 172553429697 60674183017 13155506385 85565990030 188380679354 132653620072 213967471779 69226440539 137641624766 166302397011 221523969131 80847981443 46376261447 37662245837 106741029379 130318611384 221523968061 93106503930 230318554599 ...
result:
ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 12332kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 1000 10000 2 1000 36612285378 23369050451 152360966961 15872520226 182265836399 188728204731 213864007043 57066096669 80835239061 207526883647 43857790862 65146624890 89690753835 154413657390 20424038673 49803808788 126917115886 52711828720 118899204834 158725...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 66580596995 198079362901 188002837585 194288360880 167111986766 73714107129 222229390881 108513769364 159439969371 25424526704 108513769364 25424526704 186703323340 108513769364 10576002438 140488624579 62066832985 36920571209 157371466325 100548265663 15330145069...
result:
ok
Test #17:
score: 0
Accepted
time: 2ms
memory: 12128kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 1000 10000 2 1000 4337004497 176521204259 51880125384 34694128785 180975708661 218870562416 97250810605 114586115166 24846112541 64565181841 125706138427 91643555516 73078310445 109339605796 117687618529 131699541732 8692016529 131699546538 62862679197 2229305...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 57488656585 119672114103 159363389223 80550700997 193898735338 201967251391 209771544023 186206211435 61144668391 178885696551 195291238682 205565526206 108392081703 148442568746 201967251391 122724619987 186206206389 39694619414 108392081703 61144668391 396946227...
result:
ok
Test #18:
score: 0
Accepted
time: 2ms
memory: 12796kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 1 1000 1 2 1000 655 476 606 503 746 669 142 668 383 118 398 946 53 282 396 67 739 265 86 976 405 472 467 350 740 326 426 516 763 329 894 645 782 34 390 44 614 387 539 527 88 437 978 873 155 46 190 725 613 957 111 342 605 483 295 333 766 981 177 716 371 424 572 338 70...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 759 863 796 178 489 864 882 160 829 938 525 707 820 894 910 783 458 24 945 913 265 774 764 775 890 885 844 807 803 872 869 992 784 922 792 867 888 764 682 844 962 209 363 325 726 197 793 914 821 984 772 302 689 219 840 844 774 898 776 526 945 835 976 756 812 923 9...
result:
ok
Test #19:
score: 0
Accepted
time: 2ms
memory: 12548kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 100 1000 99 2 1000 64001 97600 61200 79400 29101 55800 93800 44301 22300 74300 22201 41601 76700 29901 20101 12000 71600 27101 82100 97101 27300 41000 95901 81701 78200 55100 69800 63901 20901 72301 19700 4600 39201 1401 83900 96601 82201 59401 86101 47101 36000 5260...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 99300 91701 51901 31500 15200 102101 97700 98400 35101 66300 65200 36101 63200 97600 94900 26301 47900 30800 29700 59701 108501 104601 85901 23401 85701 24401 84801 93900 102900 100201 86100 99000 52900 91701 56601 66101 92100 19001 92800 85500 95200 92501 104300 ...
result:
ok
Test #20:
score: 0
Accepted
time: 2ms
memory: 13140kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 100023 1000 99969 2 1000 71100012 35700009 8700018 61050026 83400030 54450025 54750038 120450017 64800013 10500023 76800032 16050036 78600027 63600045 66150037 145800039 60150037 121800000 106050014 87750006 99900036 17250014 133500018 147300004 1200020 89250004 1995...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 10146301067 10132551175 10106701119 10124101130 10152451038 10013351130 10151051088 10109651134 10135451092 10065251142 10146301067 10030801116 10140450968 10147551038 10118151062 10133651147 10017001154 10124101130 10072951004 10131001083 10151400931 10048301151 ...
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 10000 1000 100 2 1000 518750000 156250000 616250000 28750000 330000000 76250000 546250000 478750000 177500000 190000000 426250000 356250000 471250000 58750000 387500000 408750000 558750000 428750000 597500000 112500000 555000000 215000000 617500000 168750000 46000000...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 287250000 546163278 472230595 332250000 589965320 564195418 90709123 469750000 593482524 15456025 469750000 364750000 147250000 602250000 256721924 190332096 206670991 139750000 626233926 218500000 373941180 478939882 99939212 387250000 155407640 467136517 8165238...
result:
ok
Test #22:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 10000 1000 100 2 1000 15750000 13500000 181500000 367500000 188250000 183000000 294750000 45750000 233250000 1500000 48750000 186750000 308250000 362250000 324000000 249000000 50250000 193500000 207000000 215250000 68250000 111000000 189750000 60000000 204750000 3112...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 4537693 25000000 150676482 172359551 298208750 295442591 370000000 326661512 121535016 58028889 275245071 240466612 286282573 49750000 264250000 271637019 304490046 245500000 34750000 292750000 93250000 325687081 341500000 166750000 374500000 115816035 189986704 1...
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 5912kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 100 10000 2 100 16997989753 22378679076 22455180036 21827670855 22450246771 29885191088 199 29885189691 4002502386 30773676142 7463505926 23130680797 30617693792 17085668681 22363171334 22377675195 12210508866 16991511620 12127457814 17211006625 3121501383 305...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 17210507896 17210507896 33946682372 35163191163 27379170855 27379171334 39375196452 27379171334 9046501383 17210507837 35823194285 35823194285 27457179645 9046501317 35823193927 12492004312 27379170848 27457179076 26266669449 27457179076 17210507896 9046501485 351...
result:
ok
Test #24:
score: 0
Accepted
time: 1ms
memory: 6140kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 100 10000 2 100 23563110896 19551607847 15326098079 5792588892 16565101743 17307606838 1301500802 12063597866 4397002030 5691005559 6597589725 19674609121 12062594807 12058594487 23710612088 16571604124 28077618265 4876503793 5792548773 30488623266 28077619241...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 33077612560 21572601743 10802503793 33077618195 33077614213 39485126271 33077612560 37565623512 13521088892 33077614213 10284502030 17064094487 33077613967 25017606327 33077614923 39485126271 35517622912 9750000802 17064094487 37565624969 10802503793 17064091963 3...
result:
ok
Test #25:
score: 0
Accepted
time: 1ms
memory: 5888kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 500000 100 10000 2 100 6908543005 2238503286 13208053985 15680057439 24239066648 12970379595 17323563662 17323063417 6909043248 2243042488 6918047069 13205053732 26565068716 31814348865 6918048027 2210002506 29963344170 22615565814 17323063417 13211556372 31855352038...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 31805568018 14836548027 11918542952 11918542488 22323561103 14836548027 11918542488 18212052351 36855846284 18212052351 22323563474 22323558682 31805568018 22323557326 22323557326 7250000019 36631345373 22323563417 35019343547 27616565238 7250001633 35019343547 22...
result:
ok
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%