QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312906 | #5264. Wyprzedzanie | tuxuanming2024 | 30 | 23ms | 13132kb | C++14 | 1.6kb | 2024-01-24 14:44:01 | 2024-01-24 14:44:01 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef LOCAL
#include "txm/debug.h"
#endif
using namespace std;
typedef long double ld;
typedef long long ll;
const int N=100005;
const ld eps=1e-8;
int n,D,d[N],x[N],nxt[N],p[N][17],ans;
ld V,v[N],t[N],pos[N];
ll s[N];
bool iseq(ld x,ld y) {return fabs(x-y)<eps;}
ld ask(int a,ld tt)
{
if(tt<t[a]) return x[a]+v[a]*tt;
int y=a;
for(int i=16;i>=0;i--)
if(p[y][i]&&(tt>t[p[y][i]]||iseq(t[p[y][i]],tt))) y=p[y][i];
tt-=t[y];
return pos[y]+v[p[y][0]]*tt-(s[y]-s[a]);
}
signed main()
{
int w,m;
scanf("%d %d %d %d",&n,&D,&w,&m),V=(ld)w/m;
for(int i=1;i<=n;i++)
{
scanf("%d %d %d %d",x+i,d+i,&w,&m);
v[i]=(ld)w/m,s[i]=s[i-1]+d[i];
}
nxt[n]=n+1,t[n]=1e19,pos[n]=x[n];
for(int i=n-1;i>=1;i--)
{
nxt[i]=i+1;
while(nxt[i]<=n&&(v[i]<v[nxt[i]]||iseq(v[i],v[nxt[i]]))) nxt[i]=nxt[nxt[i]];
if(nxt[i]>n) {t[i]=1e19,pos[i]=x[i]; continue;}
int to=nxt[i];
ld tt=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
if(tt>t[to]||iseq(tt,t[to]))
{
for(int j=16;j>=0;j--)
{
int k=p[nxt[i]][j];
if(!k) continue;
tt=(x[k]-x[i]-(s[k]-s[i]))/(v[i]-v[k]);
if(tt>t[k]||iseq(tt,t[k])) to=k;
}
to=p[to][0];
}
p[i][0]=to;
t[i]=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
pos[i]=x[i]+v[i]*t[i];
for(int j=1;1<<j<=n;j++) p[i][j]=p[p[i][j-1]][j-1];
}
for(int i=1;i<=n;i++)
{
ld tt=0;
int j=i;
for(int k=16;k>=0;k--)
{
int fa=p[j][k];
if(!fa) continue;
if(V*t[fa]<pos[fa]) j=fa;
}
tt=(x[j]-(s[j]-s[i-1]))/(V-v[j]);
ld L=ask(i,tt)-d[i]-ask(i-1,tt);
if(i==1||L>D||iseq(L,D)) ans++;
}
printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 18ms
memory: 12160kb
input:
100000 9 445 874 1653 9 34 792 2736 336 34 792 21599 862 34 792 23975 188 34 792 41891 401 34 792 62576 193 34 792 74285 567 34 792 78959 2850 34 792 85316 452 34 792 92188 217 34 792 97244 3526 34 792 106804 599 34 792 112500 1352 34 792 120610 581 34 792 123644 213 34 792 123754 16 34 792 125589 4...
output:
99905
result:
ok single line: '99905'
Test #2:
score: 0
Accepted
time: 15ms
memory: 10524kb
input:
100000 42 423 459 37434 62 373 551 55489 515 373 551 58121 1271 373 551 62626 1237 373 551 85240 1500 373 551 100367 2450 373 551 103859 766 373 551 105195 647 373 551 113654 79 373 551 116413 2078 373 551 123362 157 373 551 128320 670 373 551 130075 1030 373 551 146426 397 373 551 155828 1195 373 5...
output:
99539
result:
ok single line: '99539'
Test #3:
score: 0
Accepted
time: 18ms
memory: 10800kb
input:
100000 514 651 267 5878 637 349 559 8958 1820 349 559 19500 1747 349 559 26299 1243 349 559 27584 995 349 559 30038 128 349 559 41755 367 349 559 46773 28 349 559 57112 3790 349 559 77098 1945 349 559 79912 346 349 559 81176 1071 349 559 96565 1741 349 559 99869 1267 349 559 105062 1131 349 559 1225...
output:
94212
result:
ok single line: '94212'
Test #4:
score: 0
Accepted
time: 20ms
memory: 13128kb
input:
100000 6903 385 122 27659 90 660 238 29771 3 660 238 33082 45 660 238 36254 55 660 238 37436 36 660 238 49934 126 660 238 56662 21 660 238 64037 20 660 238 70132 223 660 238 73123 37 660 238 74391 106 660 238 87544 26 660 238 90127 179 660 238 95773 66 660 238 108314 4 660 238 111360 113 660 238 115...
output:
49159
result:
ok single line: '49159'
Test #5:
score: 0
Accepted
time: 18ms
memory: 13132kb
input:
100000 47429 212 203 11292 49 249 293 19281 41 249 293 38517 20 249 293 65772 24 249 293 73342 63 249 293 86818 112 249 293 95250 201 249 293 98973 183 249 293 132629 18 249 293 138479 87 249 293 139269 40 249 293 140399 74 249 293 141852 100 249 293 157957 20 249 293 160317 24 249 293 160534 53 249...
output:
970
result:
ok single line: '970'
Test #6:
score: 0
Accepted
time: 19ms
memory: 13064kb
input:
100000 891884 617 488 5243 119 597 691 6747 15 597 691 14373 119 597 691 17883 52 597 691 20388 113 597 691 50660 73 597 691 58923 161 597 691 63414 61 597 691 76445 157 597 691 84324 38 597 691 88647 197 597 691 97447 498 597 691 106705 34 597 691 119011 122 597 691 150042 63 597 691 164835 102 597...
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 0ms
memory: 12072kb
input:
1 1000000000 761 455 1000000000 1 737 595
output:
1
result:
ok single line: '1'
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #8:
score: 20
Accepted
time: 19ms
memory: 12976kb
input:
100000 9 984 1 13277 1519 1 998 50255 1248 1 991 76049 794 1 979 78294 128 1 978 84461 2332 1 969 117959 2101 1 943 138836 3303 1 932 139565 418 1 932 143805 216 1 928 150460 1323 1 928 153651 105 1 924 159235 175 1 898 165846 1922 1 891 174840 2016 1 886 184405 800 1 880 200807 711 1 878 210013 174...
output:
99963
result:
ok single line: '99963'
Test #9:
score: 0
Accepted
time: 23ms
memory: 13064kb
input:
100000 31 997 1 1041 5 1 998 14054 1061 1 982 20888 3270 1 970 40091 1054 1 940 44674 353 1 937 45648 271 1 931 48417 659 1 926 57508 1070 1 904 63225 55 1 900 66451 1733 1 898 68665 579 1 895 70696 1548 1 894 100516 530 1 883 103117 68 1 868 108640 723 1 862 113044 310 1 857 116930 421 1 857 120527...
output:
99800
result:
ok single line: '99800'
Test #10:
score: 0
Accepted
time: 22ms
memory: 11024kb
input:
100000 822 1000 1 2968 768 1 1000 21579 31 1 999 25773 1431 1 996 27447 1036 1 982 34954 255 1 982 50345 3194 1 967 59666 469 1 960 95568 2012 1 942 116776 4462 1 938 130891 1467 1 929 135657 148 1 893 137747 2 1 880 141581 2150 1 879 160529 225 1 872 170809 1500 1 872 171997 727 1 861 182071 189 1 ...
output:
91841
result:
ok single line: '91841'
Test #11:
score: 0
Accepted
time: 23ms
memory: 10640kb
input:
100000 5379 992 1 16416 11 1 997 20030 59 1 997 31208 298 1 994 35979 19 1 986 37550 80 1 981 54939 36 1 913 58490 123 1 913 62154 34 1 909 62613 20 1 862 68902 63 1 861 74561 18 1 846 82073 36 1 842 101997 112 1 842 109319 10 1 819 127017 44 1 810 132013 108 1 809 148866 11 1 804 183313 20 1 802 19...
output:
59408
result:
ok single line: '59408'
Test #12:
score: 0
Accepted
time: 18ms
memory: 10600kb
input:
100000 38590 1000 1 9503 122 1 994 9862 113 1 984 12816 72 1 951 18952 35 1 937 46312 281 1 931 59176 99 1 930 60739 30 1 928 66948 152 1 910 69161 62 1 894 74109 22 1 886 85758 114 1 881 106054 21 1 880 120363 81 1 877 134005 21 1 865 136631 39 1 864 147254 102 1 851 154084 73 1 850 158311 3 1 816 ...
output:
3428
result:
ok single line: '3428'
Test #13:
score: 0
Accepted
time: 19ms
memory: 13072kb
input:
100000 990557 987 1 11760 171 1 995 13375 117 1 988 16115 232 1 983 48046 63 1 970 58961 121 1 940 62062 40 1 933 64806 3 1 909 92075 144 1 905 107413 27 1 902 109695 80 1 899 120050 37 1 895 140820 4 1 875 146407 7 1 874 155458 143 1 861 162536 104 1 857 171054 174 1 856 175081 69 1 841 176075 37 1...
output:
199
result:
ok single line: '199'
Test #14:
score: 0
Accepted
time: 0ms
memory: 10040kb
input:
1 1000000000 859 157 1000000000 1 583 629
output:
1
result:
ok single line: '1'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 2ms
memory: 12012kb
input:
1000 5 716 3 632 108 255 785 1891 115 699 140 2143 130 778 315 3409 155 450 486 7330 57 351 675 10955 24 959 657 13151 127 37 429 13903 115 749 82 15213 37 267 276 15906 168 971 23 17068 74 751 600 18435 207 306 662 18493 4 463 490 18882 60 381 293 22184 64 888 663 27168 89 962 190 28751 121 122 898...
output:
526
result:
wrong answer 1st lines differ - expected: '527', found: '526'
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%