QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360799#3276. 出题高手zlxFTH15 723ms107872kbC++142.1kb2024-03-22 09:34:052024-03-22 09:34:05

Judging History

你现在查看的是最新测评结果

  • [2024-03-22 09:34:05]
  • 评测
  • 测评结果:15
  • 用时:723ms
  • 内存:107872kb
  • [2024-03-22 09:34:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)

using LL = long long;
const int N = 5e5 + 5;

int n, m, L[N], R[N];
LL a[N], s[N], mn[20][N], mx[20][N];
vector<int> q[N], P[N];
struct Node {
  LL x, y;
  Node(LL x = 0, LL y = 1) : x(x), y(y) {}
} c[N], ans[N];
void cmax(Node &a, const Node &b) {
  if (a.x * b.y < a.y * b.x) a = b;
}

LL up(LL x, LL y) {
  if (x % y == 0) return x / y;
  return x / y + 1;
}

#define lowbit(x) (x & -x)
void mdf(int x, Node v) {
  for (int i = x; i <= n + 1; i += lowbit(i)) cmax(c[i], v);
}
Node qry(int x) {
  Node res;
  for (int i = x; i > 0; i -= lowbit(i)) cmax(res, c[i]);
  return res;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  partial_sum(a, a + n + 1, s);
  for (int i = 0; i <= n; ++i) mn[0][i] = mx[0][i] = s[i];
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i + (1 << j) - 1 <= n; ++i) {
      mn[j][i] = min(mn[j - 1][i], mn[j - 1][i + (1 << j - 1)]);
      mx[j][i] = max(mx[j - 1][i], mx[j - 1][i + (1 << j - 1)]);
    }
  }
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> L[i] >> R[i], --L[i];
    q[R[i]].push_back(i);
  }
  int cnt = 0;
  for (int l = 0; l < n; ++l) {
    LL x = 0, y = 1;
    for (int r = l + 1; r <= n; ++r) {
      auto check = [&](LL A, LL B) {
        return x * (r - l) < abs(A - B) * abs(A - B) * y;
      };
      if (r + 64 <= n && !check(mn[8][r], s[l]) && !check(mx[8][r], s[l])) {
        r += 63;
      } else {
        if (x * (r - l) < (s[r] - s[l]) * (s[r] - s[l]) * y) {
          x = (s[r] - s[l]) * (s[r] - s[l]);
          y = r - l;
          P[r].push_back(l);
          ++cnt;
        }
      }
    }
  }
  for (int r = 1; r <= n; ++r) {
    for (auto l : P[r]) {
      mdf(n - l + 1, Node((s[r] - s[l]) * (s[r] - s[l]), r - l));
    }
    for (auto id : q[r]) {
      ans[id] = qry(n - L[id] + 1);
    }
  }
  for (int i = 1; i <= m; ++i) {
    LL g = __gcd(ans[i].x, ans[i].y);
    cout << ans[i].x / g << " " << ans[i].y / g << "\n";
  }
  return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 30ms
memory: 44644kb

input:

2000
-113 314 -664 697 211 -199 -38 -190 8 -661 910 -811 -113 942 77 433 -261 -368 129 -525 968 -608 -21 38 -562 438 -935 -228 220 333 985 -430 916 586 764 476 794 664 383 503 206 -60 380 -130 -988 -904 -996 -304 -286 31 114 119 850 -942 714 -369 -842 250 -192 -462 -727 -427 -602 126 231 718 121 559...

output:

54826875 11
14638276 7
1185921 1
81018001 24
6310144 3
12545764 5
3362000 1
23068809 8
23068809 8
12545764 5
1444908 1
5424241 3
1083603 1
2140369 1
2752281 2
3095072 1
3003289 2
4959529 2
17106496 13
4780232 1
89605156 31
8543929 4
129163225 48
5094049 2
68591524 23
8543929 4
35688676 11
3775249 1
...

result:

ok 200000 numbers

Test #2:

score: 0
Accepted
time: 33ms
memory: 44512kb

input:

2000
717 273 112 -879 -487 -164 -403 -895 391 721 223 895 -34 146 -779 -84 253 44 690 716 975 -625 844 731 204 457 -790 349 -739 610 -536 -561 721 -868 -967 68 729 878 672 -158 -395 -836 383 -634 -371 -262 -443 -123 -20 354 198 171 681 -390 -964 954 735 713 -904 -900 -522 561 -639 -86 326 -479 448 -...

output:

82773604 23
58201641 20
2289169 1
40500496 19
1849372 1
12759184 5
2896804 1
14775048 7
7636232 5
1806005 1
3179089 2
26388769 16
1638050 1
2778889 2
156275001 49
17181522 7
2289169 1
6817321 3
758912 1
40500496 19
4941729 2
8276763 5
5841889 3
3250809 2
1806005 1
2289169 1
156275001 49
9684544 5
25...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 23ms
memory: 44576kb

input:

2000
-851 -108 -432 344 -251 251 529 923 363 -346 416 -296 -686 832 565 66 150 -492 70 0 -977 -275 -454 -409 -979 353 -511 -458 -403 632 250 -689 -15 773 664 -386 931 -866 436 -213 711 -961 662 -849 -286 -143 -7 -933 960 -523 135 -609 86 408 643 -147 437 411 -580 -184 735 -968 417 977 863 325 518 83...

output:

15984004 5
2520500 1
49900050 19
28451556 13
12830724 5
2975625 2
24157225 11
1733522 1
11909401 4
15864289 5
8487200 3
1733522 1
1733522 1
6993800 3
15721225 6
1937664 1
3411409 2
11377129 5
2849344 3
1594323 1
15984004 5
15864289 5
7557001 6
2050624 1
2286387 1
1733522 1
49900050 19
5320322 3
3910...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 29ms
memory: 44612kb

input:

2000
269 60 -850 537 -525 -153 877 649 998 -864 -642 -77 -69 -127 537 315 -521 -922 -629 277 162 -541 659 -572 -542 -203 -997 494 364 156 276 -780 -274 94 -410 -215 -700 -840 -906 352 972 -61 824 -973 841 80 -180 634 496 -111 934 -692 328 151 297 -13 -465 380 450 -324 -367 40 318 -447 -820 -340 -107...

output:

41190724 9
1872300 1
3530641 1
12061729 7
17032129 6
7873636 3
21641104 7
100876808 37
7946761 5
10246401 4
1836025 1
12061729 7
1836025 1
2490010 1
1687500 1
7946761 5
3613801 2
14768649 5
11404129 5
7873636 3
22033636 15
10246401 4
10067929 4
1453248 1
41190724 9
9006001 5
1718658 1
5428900 3
4452...

result:

ok 200000 numbers

Test #5:

score: -5
Wrong Answer
time: 28ms
memory: 44800kb

input:

2000
599 530 -362 736 -402 -252 901 -481 318 -100 716 -726 221 -887 217 455 -516 -948 -10 -963 -373 42 -968 -949 -440 -643 -649 35 197 64 -141 -465 -975 -804 -735 -847 396 100 -131 219 543 571 -566 653 -308 725 105 668 -509 416 309 -945 260 -302 -704 -914 -648 495 -595 32 -831 -607 -104 373 -810 -12...

output:

1154640400 203
2812329 1
11826721 4
35224225 11
3276726 1
74528689 18
11539609 5
24433249 12
1431432 1
17884441 6
51739249 12
2339280 1
1565001 1
2354988 1
3276726 1
1920800 1
11539609 5
21846050 11
964324 1
11548332 5
5433561 4
142324900 29
31102929 17
35224225 11
1569992 1
8720209 4
8892324 5
6165...

result:

wrong answer 15549th numbers differ - expected: '7689529', found: '585225'

Subtask #2:

score: 15
Accepted

Test #6:

score: 15
Accepted
time: 400ms
memory: 81344kb

input:

100000
754 792 -680 426 425 347 481 -690 530 378 73 -907 -431 45 -530 -552 440 -890 -15 712 695 -679 -310 13 718 805 193 -291 -877 -74 -355 511 -679 -395 166 -710 -657 -19 874 26 832 507 854 -289 700 -404 472 -302 -977 8 -698 40 766 705 369 838 700 -964 552 -535 -75 -608 -181 -503 468 447 772 904 -2...

output:

466344025 67

result:

ok 2 number(s): "466344025 67"

Test #7:

score: 0
Accepted
time: 450ms
memory: 85032kb

input:

100000
-387 -313 -47 -714 -74 239 8 591 541 -633 -660 981 -230 -148 -813 -802 -108 -543 -640 50 962 137 -972 -936 -975 885 793 -541 932 861 -348 885 -280 -977 -677 964 355 604 54 -977 -548 979 -516 136 437 -697 -23 -748 492 897 -538 785 617 -840 675 -978 307 -288 -493 682 678 -623 613 762 -622 -283 ...

output:

2417885584 385

result:

ok 2 number(s): "2417885584 385"

Test #8:

score: 0
Accepted
time: 457ms
memory: 85500kb

input:

100000
-127 303 92 -235 -794 293 -272 199 -175 693 -799 -750 -501 -283 -358 -657 -867 -152 -399 -299 530 -5 285 959 390 -928 617 -478 -889 -133 -492 -855 986 -664 -984 -690 887 -738 39 -570 -268 -767 640 883 711 -748 -75 426 -268 -541 -926 -792 902 214 561 -428 -285 781 -225 -299 -233 134 -896 569 -...

output:

202236841 30

result:

ok 2 number(s): "202236841 30"

Test #9:

score: 0
Accepted
time: 723ms
memory: 107872kb

input:

100000
-340 -696 48 -515 -584 -60 -888 257 214 -889 782 915 905 -964 -536 459 779 -519 -338 -867 622 -902 655 -153 600 -117 269 -887 -242 -985 -267 132 406 98 -368 400 -871 -908 -489 118 -140 -755 -869 -943 965 609 47 -748 194 -160 994 527 871 119 -891 580 -687 865 826 56 -978 -775 -47 792 313 -944 ...

output:

272184004 39

result:

ok 2 number(s): "272184004 39"

Test #10:

score: 0
Accepted
time: 419ms
memory: 82404kb

input:

100000
-736 -691 738 209 -411 -136 792 -110 -441 -753 254 744 -958 -317 312 856 245 995 912 87 -830 131 393 37 -400 934 279 -784 -308 618 -647 967 527 -162 -874 -770 188 -917 -855 772 482 -373 -749 -40 80 -459 710 -354 221 -343 -132 -947 -445 62 -744 851 848 554 -530 -892 -721 -910 -642 -138 -480 -7...

output:

393070276 51

result:

ok 2 number(s): "393070276 51"

Subtask #3:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

500000
794 -75 -596 -322 -945 -908 -609 -164 488 626 -877 -710 140 -120 -475 -837 738 669 634 -643 -682 667 816 -785 -608 -836 -860 -932 242 70 -620 268 -121 288 209 -392 732 750 558 -480 565 327 -217 -891 767 211 -690 -66 813 -889 952 615 432 19 411 800 678 718 522 422 940 -510 -544 449 -357 640 40...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #16:

score: 15
Accepted
time: 410ms
memory: 83944kb

input:

100000
-496 -233 354 -632 -196 177 -878 -255 -19 -636 685 -70 101 -975 -406 -988 -965 -205 563 -766 763 511 -116 -746 -129 14 106 928 -457 -257 -283 226 3 899 -359 -792 615 490 -57 986 -243 624 -239 931 -555 -821 -72 -611 -380 -397 248 -132 956 -195 -322 -231 319 -214 837 -379 -931 -301 -4 -673 280 ...

output:

1352474176 205
13957947 4
67914081 16
33243858 7
10885778 3
27836176 7
50680161 11
235284921 74
106770889 25
2411809 2
2835045 1
14017536 5
134699236 43
286523329 74
28100601 11
17546888 5
23396569 6
80839443 25
4012009 3
2661336 1
42947912 11
3474284 1
61496964 19
3672245 1
6120676 3
7573504 3
1489...

result:

ok 10000 numbers

Test #17:

score: 0
Accepted
time: 559ms
memory: 93588kb

input:

100000
-869 53 -81 127 179 138 -838 925 306 178 -55 -225 -567 534 949 -510 713 -280 -889 370 708 258 -726 -235 17 41 51 -405 -889 647 -308 997 -219 84 -271 662 -139 -492 979 -103 -624 732 606 -629 -40 242 231 -23 -332 524 -963 -991 366 790 691 902 536 476 -799 959 150 931 794 -601 794 942 598 148 11...

output:

84621601 13
58094884 11
119880601 30
101929216 29
146482609 33
214066161 52
223353025 54
491996761 112
12616704 5
1132096 1
6633507 2
45603009 14
89397025 26
665898025 103
61449921 19
5938947 2
13069100 3
44382244 11
9834496 5
3317760 1
18037009 6
35162498 11
4385829 1
27331984 7
48135844 13
6473883...

result:

ok 10000 numbers

Test #18:

score: 0
Accepted
time: 509ms
memory: 89236kb

input:

100000
-640 205 550 38 938 622 -23 525 -242 554 772 -491 -11 -567 -243 -59 -449 449 -691 805 -822 -486 111 -166 -379 994 645 704 197 -932 654 -349 382 60 -101 -872 -506 645 453 736 -699 965 -988 -149 758 891 -595 772 648 545 122 3 -239 523 -140 996 612 793 -883 932 809 -285 228 873 371 739 648 616 7...

output:

130553476 17
5112121 3
502681 1
210665405 39
739600 1
28504921 7
6956450 3
8898289 4
418609 1
765075600 109
2512225 1
21451250 7
21635042 5
45212176 11
312865344 49
3682561 2
380689 1
451584 1
3195392 1
1909620 1
1973163 1
35343025 8
11546404 7
82150562 25
80209936 23
82210489 15
1723969 2
141376 1
...

result:

ok 10000 numbers

Test #19:

score: 0
Accepted
time: 534ms
memory: 91636kb

input:

100000
762 -774 -441 -718 454 -111 -614 526 363 545 308 -159 572 -894 967 299 -866 -201 -553 -312 -634 365 265 25 308 -232 -380 -361 654 656 -522 -815 -18 955 -954 -854 111 879 -575 753 -996 885 -188 389 478 -11 -437 0 -546 289 -266 708 566 -932 -843 -38 -531 440 227 857 -697 -109 371 96 70 -271 -3 ...

output:

52654322 9
52654322 9
12180100 7
444830281 67
1944075 1
101124 1
20079361 5
39463524 11
51825601 20
1678112 1
23726641 6
5896178 3
6436369 3
15961250 3
354025 1
9006001 6
12082576 5
312936100 63
123187801 24
11135569 4
26122321 5
48986001 8
205434889 34
1860500 1
87781250 17
145226601 31
444830281 6...

result:

ok 10000 numbers

Test #20:

score: 0
Accepted
time: 455ms
memory: 86272kb

input:

100000
227 -437 -47 722 -894 -928 -542 859 -798 -393 -429 -319 -432 106 -732 -793 420 542 -313 -907 146 638 -169 618 873 -699 747 62 -977 983 275 194 -216 -511 647 960 1000 -712 -797 -299 53 458 -598 581 -251 770 965 214 382 135 21 547 747 -499 -564 -256 -517 635 788 -88 -919 302 201 -600 -588 47 -9...

output:

902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581849 123
902581...

result:

ok 10000 numbers

Test #21:

score: -15
Time Limit Exceeded

input:

100000
-389 -434 -758 -766 -641 -265 280 -682 623 228 -902 155 811 220 507 193 235 -915 432 -490 682 -941 -408 776 150 -691 239 -104 -728 430 -807 145 -700 224 -191 522 -839 -296 -266 885 -590 -189 705 49 456 -164 487 685 6 -919 -133 614 -311 -691 -388 47 -931 685 337 -935 386 902 -67 901 738 -562 7...

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #31:

score: 35
Accepted
time: 599ms
memory: 95388kb

input:

100000
139 -485 -497 -818 254 169 -560 22 377 -67 -243 -75 743 -788 -676 -26 -775 371 576 -303 54 733 422 800 445 687 479 -16 -288 259 783 -586 912 616 439 -416 676 -555 172 659 501 -868 337 22 -60 260 603 -982 -149 466 769 -595 -117 949 -544 904 753 20 776 175 -888 937 -792 -647 -615 59 -298 452 -6...

output:

401594700 47
3916125 1
4343056 1
23049601 8
19713600 7
62900761 15
46076944 15
6620329 2
3775805 1
7868025 4
20659592 7
66569281 16
3354050 1
48818169 10
10629610 3
44129449 10
62837329 19
10975969 2
2958400 1
6786025 2
2683044 1
3323047 1
83631025 17
10329796 3
78198649 18
7840000 3
401594700 47
65...

result:

ok 600000 numbers

Test #32:

score: -35
Wrong Answer
time: 606ms
memory: 95304kb

input:

100000
244 483 10 493 887 79 730 759 -244 -687 -602 -782 -741 80 -546 556 -11 563 231 -917 664 917 861 -265 -682 -869 -134 616 -20 703 27 163 -804 -671 854 -495 365 110 257 -462 310 151 648 -983 -716 50 953 202 320 750 -439 -611 763 -813 -545 357 108 -872 -782 816 163 613 -712 -873 -595 -754 897 100...

output:

1795301641 246
48762289 16
99380961 25
82283041 19
3441025 1
87516025 21
100217645 19
64770304 19
26460736 9
21874329 11
3656448 1
16016004 5
263900025 71
130669778 35
4118023 1
16032016 5
19331762 5
591024721 179
144 1
73736569 22
13307904 5
6185169 2
24334489 8
320123664 85
1178342929 274
51051025...

result:

wrong answer 29123rd numbers differ - expected: '7059649', found: '11082241'