QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105035 | #5170. 加速度 | stntn | 50 | 3ms | 3856kb | C++14 | 2.1kb | 2023-05-12 21:00:20 | 2023-05-12 21:00:26 |
Judging History
answer
#include<bits/stdc++.h>
#define N 5010
#define LL long long
#define ULL unsigned long long
#define DB double
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define INF 1e13
#define pir pair<int,int>
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
using namespace std;
template <typename T> inline void read(T &a)
{
a=0;T w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){a=(a<<3)+(a<<1)+(ch^48);ch=getchar();}
a*=w;
}
template <typename T,typename ...Args> inline
void read(T &x,Args &...args){read(x);read(args...);}
int n,a,s[N],l[N],r[N];
DB f[N],ans=INF;
inline DB solve_v(DB x,DB t){if(t<0) return INF;return 1.0*(x-0.5*a*t*t)/t;}
inline DB solve_t(DB x,DB v0){return (-2*v0+sqrt(4.0*v0*v0+8.0*a*x))/(2.0*a);}
signed main()
{
read(n,a);
rep(i,1,n+1) read(s[i]);
rep(i,1,n+1) read(l[i],r[i]);
rep(i,1,n+1) l[i]=max(l[i-1],l[i]);
per(i,n,1) r[i]=min(r[i+1],r[i]);
rep(i,1,n+1) if(l[i]>r[i]) return printf("kaibai\n"),0;
f[0]=l[1]=r[1]=0;rep(i,2,n+1) f[i]=-1;
// rep(i,1,n+1) printf("%d ",l[i]);printf("\n");
// rep(i,1,n+1) printf("%d ",r[i]);printf("\n");
rep(i,1,n) if(f[i]>=0)
{
// printf("begin %d ===================================\n",i);
DB L=0,R=f[i];
rep(j,i+1,n+1)
{
DB dis=s[j]-s[i],Lv=solve_v(dis,r[j]-r[i]),Rv=solve_v(dis,l[j]-r[i]);//最低要求速度,最高允许速度
L=max(L,Lv);R=min(R,Rv);if(L>R) break;
// printf("to %d for v L=%.3lf R=%.3lf\n",j,L,R);
f[j]=max(f[j],Lv+(r[j]-r[i])*a);//用最长的时间加速
if(j==n+1) ans=min(ans,r[i]+solve_t(s[n+1]-s[i],R));//直接到终点
}
L=0,R=r[i+1]-r[i];
rep(j,i+1,n+1)
{
DB dis=s[j]-s[i],t=sqrt(2*dis/a);
DB Lt=l[i+1]-r[i]-t,Rt=r[i+1]-r[i]-t;//最低等待时间,最高等待时间
L=max(L,Lt);R=min(R,Rt);if(L>R) break;
// printf("dis=%.3lf t=%.3lf\n",dis,t);
// printf("to %d for t L=%.3lf R=%.3lf\n",j,L,R);
f[j]=max(f[j],a*t);
if(j==n+1) ans=min(ans,r[i]+L+t);//直接到终点
}
}
if(ans>=INF-10) return printf("kaibai\n"),0;
printf("%.5lf\n",ans);
return 0;
}
详细
Subtask #1:
score: 30
Accepted
Test #1:
score: 30
Accepted
time: 2ms
memory: 3732kb
input:
4 2 0 2 8 10 12 0 1000000000 2 2 4 4 6 7 6 1000000000
output:
6.58579
result:
ok found '6.58579', expected '6.58579', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
5 1 0 1 2 3 4 5 0 1000000000 1 2 2 3 3 4 4 5 5 6
output:
5.00000
result:
ok found '5.00000', expected '5.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
2 1 0 2 8 0 1000000000 4 1000000000 0 1000000000
output:
6.00000
result:
ok found '6.00000', expected '6.00000', error '0.00000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
4 2 0 121 484 520 628 0 1000000000 5 17 11 33 31 33 37 39
output:
37.00000
result:
ok found '37.00000', expected '37.00000', error '0.00000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
6 3 0 216 864 901 1014 1188 1437 0 1000000000 6 18 12 36 34 35 39 41 44 45 49 50
output:
49.00000
result:
ok found '49.00000', expected '49.00000', error '0.00000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
10 1 0 24 98 214 380 440 622 816 1075 1296 1554 0 1000000000 6 8 13 15 20 21 13 42 37 47 47 59 60 62 62 76 74 76 80 81
output:
80.00000
result:
ok found '80.00000', expected '80.00000', error '0.00000'
Subtask #2:
score: 20
Accepted
Test #7:
score: 20
Accepted
time: 2ms
memory: 3644kb
input:
3 20 0 4632 5697 8786 0 1000000000 1 1000000000 1 1000000000 1 1000000000
output:
29.64119
result:
ok found '29.64119', expected '29.64119', error '0.00000'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
5000 100 0 26 289 325 425 558 844 885 1020 1186 1385 1398 1414 1444 1470 1914 1932 1956 2127 2194 2316 2339 2419 2521 2567 2647 2655 2804 3016 3053 3102 3240 3294 3491 3540 3591 3642 3680 3763 3804 3865 3955 3997 4048 4053 4100 4212 4222 4238 4302 4354 4358 4532 4534 4547 4550 4551 4695 4761 4762 48...
output:
100.27779
result:
ok found '100.27779', expected '100.27779', error '0.00000'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
3 300 0 44 217 225 0 1000000000 1 1000000000 1 1000000000 1 1000000000
output:
1.68314
result:
ok found '1.68314', expected '1.68314', error '0.00000'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3488kb
input:
3 300 0 211 253 273 0 1000000000 1 1000000000 1 1000000000 1 1000000000
output:
1.34907
result:
ok found '1.34907', expected '1.34907', error '0.00000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
3 2 0 7 21 26 0 1000000000 1 1000000000 1 1000000000 1 1000000000
output:
5.09902
result:
ok found '5.09902', expected '5.09902', error '0.00000'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
300 300 0 5 26 46 67 75 77 94 103 104 115 116 120 152 156 174 184 203 212 227 248 259 269 278 279 280 300 305 319 320 328 332 357 360 360 372 380 390 404 409 409 420 441 455 464 467 467 503 511 536 553 568 575 597 602 607 622 626 632 637 645 672 673 674 680 681 688 700 705 707 710 710 730 748 753 75...
output:
5.28882
result:
ok found '5.28882', expected '5.28882', error '0.00000'
Test #13:
score: 0
Accepted
time: 3ms
memory: 3856kb
input:
5000 100 0 12 33 57 92 94 120 157 208 220 222 236 236 237 238 247 259 317 323 358 361 365 383 396 431 441 498 506 517 542 542 544 545 571 590 598 626 630 639 639 668 670 674 684 693 693 694 748 753 760 760 767 785 793 798 805 820 851 852 852 867 897 916 942 945 963 969 980 986 994 1010 1014 1019 102...
output:
32.12908
result:
ok found '32.12908', expected '32.12908', error '0.00000'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
5000 2 0 96 121 212 282 332 358 388 393 464 586 666 972 998 1056 1116 1117 1313 1335 1514 1538 1573 1634 1769 1816 1819 1843 1877 1881 1901 2136 2234 2248 2355 2457 2467 2559 2676 2713 3063 3137 3232 3308 3327 3334 3373 3397 3471 3634 3720 3932 3946 3959 4032 4113 4275 4491 4792 4845 4934 4987 5032 ...
output:
707.01839
result:
ok found '707.01839', expected '707.01839', error '0.00000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3724kb
input:
3 2 0 7 11 22 0 1000000000 1 1000000000 1 1000000000 1 1000000000
output:
4.69042
result:
ok found '4.69042', expected '4.69042', error '0.00000'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3736kb
input:
300 300 0 3 10 13 28 37 62 69 89 91 98 100 136 154 159 161 161 165 178 212 225 228 241 246 253 257 267 288 293 302 303 307 320 325 327 340 345 359 363 372 382 389 394 395 401 404 408 418 447 453 458 465 466 467 468 484 485 488 495 503 506 516 563 567 570 575 578 585 586 587 599 607 612 624 628 637 6...
output:
5.32848
result:
ok found '5.32848', expected '5.32848', error '0.00000'
Subtask #3:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #17:
score: 30
Accepted
time: 2ms
memory: 3724kb
input:
121 2 0 81 324 729 1296 2025 2916 3969 5184 6561 8100 9801 10960 12191 13495 14870 16317 17837 19428 21091 22827 24634 26513 29620 32927 36434 40141 44048 48155 52462 56969 61677 66584 71691 74284 76928 79621 82365 85158 88002 90895 93839 96832 99876 102969 106612 110327 114114 117973 121905 125908 ...
output:
989.00000
result:
ok found '989.00000', expected '989.00000', error '0.00000'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
104 3 0 121 486 1076 1910 2319 2777 3746 4908 6033 7305 7359 7521 7592 7676 7682 7700 7853 8153 8515 8985 9162 9352 10464 11877 12509 13189 13521 13866 15594 17622 18680 19813 21674 23728 26437 29446 30331 31243 33129 35123 36438 37801 39556 41386 42823 44309 45434 46587 50156 53969 58462 63255 6565...
output:
548.00000
result:
ok found '548.00000', expected '548.00000', error '0.00000'
Test #19:
score: -30
Wrong Answer
time: 0ms
memory: 3408kb
input:
228 4 0 98 392 882 932 1082 1332 1848 2560 3469 4237 5105 6073 8210 10747 13684 16137 18847 21813 26194 31060 36410 38879 41448 44118 49703 55689 62074 67044 72271 77754 86198 95219 104816 114419 124598 135353 144678 154403 164528 164626 164920 165410 165869 166429 167089 168251 169669 171343 173008...
output:
kaibai
result:
wrong output format Expected double, but "kaibai" found
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%