QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769574 | #6609. Scholomance Academy | daylight-et-al# | AC ✓ | 605ms | 14380kb | D | 1.6kb | 2024-11-21 18:16:14 | 2024-11-21 18:16:16 |
Judging History
answer
import std;
class Reader {
DList!(string) buf;
private void readNext() {
while (buf.empty) {
auto inputs = stdin.readln()[0 .. $ - 1].split(" ");
foreach (token; inputs) {
buf.insertBack(token);
}
}
}
void read()() {
}
void read(T, A...)(ref T t, ref A a) {
if (buf.empty) {
readNext();
}
static if (is(T == char[])) {
string token = buf.front();
t = token.dup;
buf.removeFront();
} else static if (isArray!(T)) {
foreach (ref v; t) {
read(v);
}
} else {
t = buf.front.to!T;
buf.removeFront();
}
read(a);
}
}
ref auto chmin(T)(ref T a, T b) {
if (a > b) {
a = b;
}
return a;
}
ref auto chmax(T)(ref T a, T b) {
if (a < b) {
a = b;
}
return a;
}
public const int INF = 1 << 30;
public const long LINF = 2e18.to!long;
void main() {
Reader reader = new Reader();
int N;
reader.read(N);
alias T = Tuple!(int, char);
T[] V = new T[N];
int neg = 0, pos = 0;
foreach (i; 0 .. N) {
char C;
int X;
reader.read(C, X);
if (C == '+')
pos++;
else
neg++;
V[i] = T(X, C);
}
V.sort();
int fn = 0;
int tp = pos;
double ans = 0;
foreach (t; V) {
char c;
int x;
AliasSeq!(x, c) = t;
if (c == '-') {
ans += double(1) / neg * tp / pos;
} else {
tp--;
}
}
writef("%.10f\n", ans);
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
3 + 2 - 3 - 1
output:
0.5000000000
result:
ok found '0.500000000', expected '0.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
6 + 7 - 2 - 5 + 4 - 2 + 6
output:
0.8888888889
result:
ok found '0.888888889', expected '0.888888889', error '0.000000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
8 + 34 + 33 + 26 - 34 - 38 + 39 - 7 - 27
output:
0.5625000000
result:
ok found '0.562500000', expected '0.562500000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
2 + 12345135 - 12345135
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
2 + 4 - 3
output:
1.0000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
2 - 3 + 4
output:
1.0000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
2 - 12 + 11
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
2 + 7 - 9
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2 - 4 + 4
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #10:
score: 0
Accepted
time: 433ms
memory: 14124kb
input:
1000000 + 1 - 1 - 1 - 1 + 1 - 1 + 1 - 1 - 1 + 1 + 1 - 1 + 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 - 1 + 1 + 1 - 1 - 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 + 1 + 1 + 1 - 1 + 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 1 - 1 + 1 - 1 + 1 + 1 - 1 + 1 + 1 - 1 + 1 - 1 + 1 + 1 + 1 + 1 + 1 - 1 - 1 + 1 ...
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #11:
score: 0
Accepted
time: 438ms
memory: 14020kb
input:
999999 + 2 - 1 + 1 - 2 + 2 - 1 - 1 + 1 - 2 + 2 - 1 - 2 + 1 - 2 - 1 + 2 - 2 - 1 - 1 - 2 + 2 + 1 - 1 - 2 + 2 + 1 - 1 - 1 + 2 - 2 + 2 - 1 + 1 + 1 - 2 + 2 + 1 + 2 + 1 + 2 - 2 + 1 - 2 + 1 - 2 + 2 + 2 - 1 - 1 - 1 + 2 + 1 + 2 - 1 - 1 - 2 + 2 - 1 + 2 - 2 - 2 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 1 - 2 - 2 - 1 - 1 -...
output:
0.2497381374
result:
ok found '0.249738137', expected '0.249738137', error '0.000000000'
Test #12:
score: 0
Accepted
time: 437ms
memory: 14328kb
input:
1000000 + 2 + 1 - 2 - 1 + 2 - 1 + 1 + 1 - 1 + 2 - 2 + 1 + 2 - 1 - 2 - 1 + 2 + 1 + 2 - 1 - 2 - 2 - 1 - 1 + 1 - 1 - 1 - 1 - 1 - 2 - 1 + 2 - 1 + 1 - 1 + 2 + 1 + 1 - 2 + 1 + 1 + 2 - 2 - 2 - 1 - 1 - 1 + 2 + 2 + 1 - 1 + 2 - 1 + 2 - 2 + 1 - 1 + 1 + 2 + 1 - 1 + 1 + 1 + 2 - 2 + 2 + 2 - 1 + 1 - 2 + 2 + 1 + 1 ...
output:
0.2494917819
result:
ok found '0.249491782', expected '0.249491782', error '0.000000000'
Test #13:
score: 0
Accepted
time: 469ms
memory: 13564kb
input:
999999 + 20 - 6 + 13 - 20 - 19 + 17 + 13 - 8 + 3 + 6 - 17 + 17 + 16 - 16 + 8 + 11 - 7 - 20 - 13 + 6 - 7 + 19 + 10 - 5 - 9 - 16 - 17 + 13 + 7 + 18 - 17 + 13 + 16 + 10 + 17 - 9 - 6 + 11 - 7 + 8 - 5 + 20 - 18 + 1 + 8 - 9 + 4 + 5 + 14 - 11 - 15 - 8 - 7 - 7 + 15 + 15 + 8 - 3 + 13 - 5 + 9 - 14 + 6 - 8 + 3...
output:
0.4741537115
result:
ok found '0.474153712', expected '0.474153712', error '0.000000000'
Test #14:
score: 0
Accepted
time: 463ms
memory: 12600kb
input:
1000000 + 22 - 6 + 13 - 20 - 19 + 24 + 24 - 15 + 17 + 3 + 23 + 20 - 17 + 23 + 16 - 21 - 22 + 8 + 11 - 23 + 17 - 24 - 13 + 6 - 7 + 19 + 21 - 14 + 18 - 22 - 11 - 21 - 21 + 13 + 24 + 20 + 18 - 17 + 13 + 16 + 10 + 25 - 24 - 14 + 7 - 15 + 22 + 8 - 5 + 20 - 18 + 1 + 8 - 9 + 4 + 25 + 1 - 9 - 9 - 14 + 14 + ...
output:
0.4795416962
result:
ok found '0.479541696', expected '0.479541696', error '0.000000000'
Test #15:
score: 0
Accepted
time: 492ms
memory: 12576kb
input:
999999 - 595 + 975 + 320 - 300 + 871 - 170 + 103 - 360 + 868 - 631 - 851 - 509 + 725 + 627 - 983 - 63 - 845 + 367 + 1000 - 980 - 846 - 605 - 987 + 582 - 367 - 724 - 579 + 944 + 566 - 873 - 889 - 991 + 562 + 209 + 625 + 328 - 463 + 673 + 77 + 365 - 275 + 667 - 424 - 85 + 942 + 504 + 447 - 90 + 780 + ...
output:
0.5003549412
result:
ok found '0.500354941', expected '0.500354941', error '0.000000000'
Test #16:
score: 0
Accepted
time: 488ms
memory: 12608kb
input:
1000000 - 18 - 59 - 824 + 193 - 373 - 462 - 707 + 765 - 285 - 664 + 186 - 374 - 360 + 295 - 339 + 144 - 88 + 96 - 103 + 809 - 453 - 624 - 509 - 435 + 158 + 503 + 160 + 194 - 579 + 135 - 276 + 605 - 564 - 549 - 219 - 246 - 399 - 893 + 166 + 749 - 551 + 729 + 787 - 507 + 563 + 222 + 767 - 117 - 232 - ...
output:
0.4996158068
result:
ok found '0.499615807', expected '0.499615807', error '0.000000000'
Test #17:
score: 0
Accepted
time: 591ms
memory: 14124kb
input:
999999 + 649917 - 505960 - 144512 - 570407 + 262265 - 623272 + 743202 - 886356 - 199591 + 951022 + 966769 + 770209 + 256025 - 118843 + 168738 + 516944 + 160812 - 283717 + 254929 - 442969 - 897288 + 74809 - 419482 - 845143 - 967020 + 883637 - 767990 - 173181 + 230007 + 638724 - 950239 + 836557 + 7156...
output:
0.4999326475
result:
ok found '0.499932647', expected '0.499932647', error '0.000000000'
Test #18:
score: 0
Accepted
time: 598ms
memory: 12652kb
input:
1000000 + 750053 + 923209 - 763652 - 396503 + 84843 - 225264 + 211824 - 199934 + 199338 + 972980 - 107119 - 690804 - 223468 + 781874 - 35507 - 846803 - 681603 + 211351 - 224207 + 72103 - 962217 + 425712 + 992688 - 246076 - 768896 + 369739 + 238902 - 578540 + 28399 + 829998 - 893623 - 200097 + 556996...
output:
0.5005322005
result:
ok found '0.500532201', expected '0.500532201', error '0.000000000'
Test #19:
score: 0
Accepted
time: 605ms
memory: 13308kb
input:
999999 - 245903924 - 483230839 + 108985430 + 539249067 - 320800640 + 848181362 + 484237694 - 459595626 + 979645696 - 948686855 - 70497963 + 674887631 + 782479996 - 668243716 + 147438342 + 435024955 - 154928249 - 389834034 + 197879974 + 739032367 + 426010178 - 682896784 - 130246237 - 740749204 + 8418...
output:
0.4994149113
result:
ok found '0.499414911', expected '0.499414911', error '0.000000000'
Test #20:
score: 0
Accepted
time: 600ms
memory: 13084kb
input:
1000000 - 853247405 + 441797910 - 766129524 - 685136985 + 584459708 - 538159424 - 800344356 + 124883688 + 161535274 - 678914022 + 567638902 - 633603171 + 298109475 - 389464136 - 544651056 + 437101725 - 294477595 + 208671579 - 441015307 - 244456728 + 484763083 + 917286399 + 531350532 - 353718014 + 17...
output:
0.5004551671
result:
ok found '0.500455167', expected '0.500455167', error '0.000000000'
Test #21:
score: 0
Accepted
time: 593ms
memory: 14380kb
input:
1000000 + 6278775 + 6076582 + 5872033 - 5301138 + 6417685 + 6112374 + 6197023 + 5353843 - 4459159 - 5291583 + 5441573 + 6067621 - 4489765 + 6025291 + 6794592 - 4381371 - 5465451 - 4135215 - 4900908 - 4987148 - 5965095 - 4607027 + 6326439 - 5421119 + 5518925 + 5957293 - 5484248 + 5506751 - 4254534 - ...
output:
0.9207456875
result:
ok found '0.920745687', expected '0.920745688', error '0.000000000'
Test #22:
score: 0
Accepted
time: 587ms
memory: 14036kb
input:
1000000 - 781328 + 9314902 + 9055461 + 8346316 - 1429049 - 1184986 - 1528431 - 162650 + 9089967 - 1207692 + 8377161 - 468712 + 10198601 + 8530637 + 9325112 - 1217371 + 8766135 + 9103679 + 8852542 - 229999 + 8836117 + 9957897 - 567800 - 1250789 - 1612427 - 112108 + 8489648 - 1301755 - 745317 + 872436...
output:
1.0000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #23:
score: 0
Accepted
time: 590ms
memory: 13664kb
input:
1000000 - 9064819 - 8916397 + 1173623 - 9021425 - 9141255 + 1387882 + 509522 + 530250 + 1743860 + 1410003 - 9448471 - 8829125 + 1731730 - 8613071 - 8384510 - 8878865 - 8624019 + 342034 - 9866078 + 1393572 + 1142802 - 9500710 + 547028 - 9281383 - 9543821 - 9515255 + 770513 + 1301904 + 809391 - 809931...
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #24:
score: 0
Accepted
time: 525ms
memory: 12972kb
input:
1000000 - 102910932 + 1000000000 + 1000000000 + 1000000000 + 1000000000 + 1000000000 + 1000000000 - 722011197 - 427630036 + 738303012 - 1 - 62996823 - 1 - 1 - 717325785 + 1000000000 + 253739553 + 522925545 - 53263035 - 576267130 - 764198673 - 1 + 149253463 - 93503980 + 910579116 - 1 + 1000000000 - 9...
output:
0.9045733975
result:
ok found '0.904573397', expected '0.904573397', error '0.000000000'
Test #25:
score: 0
Accepted
time: 529ms
memory: 12864kb
input:
1000000 - 1000000000 - 1000000000 - 638521978 - 856740900 + 328709862 + 1 - 547643875 - 1000000000 + 790604222 - 1000000000 - 868334780 - 231513670 + 1 + 185473938 + 1 - 971111142 - 651862454 - 1000000000 + 1 + 579713318 + 794684187 - 1000000000 - 1000000000 - 1000000000 - 716736759 + 1 - 1000000000...
output:
0.0720014181
result:
ok found '0.072001418', expected '0.072001418', error '0.000000000'
Test #26:
score: 0
Accepted
time: 453ms
memory: 12532kb
input:
1000000 + 1000000000 - 1000000000 - 1000000000 - 1000000000 + 1000000000 - 1000000000 - 1000000000 - 1000000000 - 1000000000 + 1000000000 + 1000000000 - 1000000000 + 1000000000 - 1000000000 + 1000000000 - 1000000000 - 1000000000 - 1000000000 - 1000000000 + 1000000000 + 1000000000 + 1000000000 + 1000...
output:
0.0000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
100 + 11 - 1 - 11 - 20 - 15 - 18 - 5 - 2 + 7 + 1 - 4 + 18 - 6 - 1 + 14 - 16 + 19 - 18 - 18 - 7 + 14 - 2 - 9 + 7 - 5 + 17 + 9 - 4 - 11 + 10 + 6 - 14 - 19 + 3 - 17 + 3 + 2 - 16 - 1 + 8 - 15 - 12 - 6 + 6 - 1 + 7 - 1 - 14 + 1 - 7 - 17 + 14 + 6 - 15 + 14 + 20 + 8 + 20 + 17 + 20 + 18 - 6 - 12 - 5 + 17 + 1...
output:
0.5118047219
result:
ok found '0.511804722', expected '0.511804722', error '0.000000000'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
1000 - 83 - 53 + 26 - 8 - 57 - 5 - 26 + 64 + 52 - 61 + 55 - 96 + 67 + 97 - 58 - 64 - 6 + 81 + 5 - 34 + 23 + 26 + 46 + 29 + 56 + 40 - 25 - 38 - 59 + 45 + 79 + 50 - 67 - 45 - 21 + 72 - 45 + 26 - 2 + 86 - 73 - 14 - 95 + 33 - 92 - 84 + 72 + 86 - 18 - 7 + 23 - 93 - 60 + 4 - 13 + 73 + 82 + 8 + 64 - 1 - 25...
output:
0.5101079246
result:
ok found '0.510107925', expected '0.510107925', error '0.000000000'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
567 + 107 - 258 - 29 + 157 + 300 + 26 + 149 - 45 - 200 + 96 - 235 - 107 - 293 - 165 + 85 - 163 - 227 + 181 + 150 + 134 - 35 + 2 - 239 + 203 - 191 + 99 + 170 + 142 - 58 + 116 + 17 + 82 - 267 + 14 + 182 - 208 + 193 + 256 - 289 - 278 + 23 - 35 + 48 - 117 + 19 + 93 - 70 - 158 - 33 - 116 + 139 + 81 + 24 ...
output:
0.4979950187
result:
ok found '0.497995019', expected '0.497995019', error '0.000000000'
Test #30:
score: 0
Accepted
time: 1ms
memory: 4052kb
input:
666 + 589 - 647 - 533 + 632 + 190 - 581 - 197 + 61 - 625 - 225 - 244 - 15 + 134 + 362 - 288 + 470 - 160 + 641 + 169 - 507 - 112 - 656 + 243 + 122 + 495 + 148 - 282 + 568 + 85 + 544 - 307 + 453 + 261 - 465 - 9 + 563 + 621 - 285 + 181 - 176 + 359 + 166 + 408 + 286 + 36 + 461 - 324 + 492 - 561 - 158 + ...
output:
0.5439870136
result:
ok found '0.543987014', expected '0.543987014', error '0.000000000'
Test #31:
score: 0
Accepted
time: 1ms
memory: 4076kb
input:
1234 - 4300 + 2279 + 3371 - 295 + 2929 + 4315 - 2312 - 1611 - 509 - 416 - 2705 - 3280 - 1834 - 2612 + 4044 - 4243 - 1611 + 3282 + 338 + 2241 - 3203 + 3162 - 1514 - 4172 - 908 + 1809 + 1196 + 4069 + 166 + 1545 + 420 - 1731 + 2312 - 1475 - 2414 + 1648 - 983 + 2261 + 2086 + 800 - 3304 - 4113 - 3570 + 2...
output:
0.5122790145
result:
ok found '0.512279015', expected '0.512279015', error '0.000000000'
Test #32:
score: 0
Accepted
time: 0ms
memory: 4860kb
input:
7831 - 4856 - 6984 - 324 - 3410 - 1604 + 7250 - 6187 + 2072 - 4085 + 2959 - 2705 + 2598 - 7299 - 1701 + 257 - 474 - 4139 + 7208 + 169 + 2079 + 2473 - 4761 - 3274 - 1877 - 5225 + 1221 - 1212 + 9079 + 878 - 2719 + 5046 + 3773 - 1637 + 4329 + 5745 + 1164 - 6296 - 967 + 8651 + 5003 - 5836 - 3172 + 6556 ...
output:
0.4980487967
result:
ok found '0.498048797', expected '0.498048797', error '0.000000000'