QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#517118 | #3276. 出题高手 | hztmax0 | 5 | 109ms | 67820kb | C++14 | 1.4kb | 2024-08-13 08:20:57 | 2024-08-13 08:20:57 |
Judging History
answer
#include <iostream>
#include <algorithm>
using namespace std;
using LL = long long;
struct Frac {
LL x, y;
Frac () : x(0), y(1) {}
Frac (LL _x, LL _y) : x(_x), y(_y) {
LL g = __gcd(x, y);
x /= g, y /= g;
}
bool operator< (Frac a) const { return (__int128)x * a.y < (__int128)a.x * y; }
void Print () { cout << x << ' ' << y << '\n'; }
};
const int N = 5e5 + 5;
int n, m;
int a[N];
namespace SolveA {
const int tN = 2e3 + 5;
int s[tN];
Frac ans[tN][tN];
int main () {
for (int i = 1; i <= n; ++i) {
s[i] = s[i - 1] + a[i];
}
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
ans[i][j] = Frac(1ll * (s[j] - s[i - 1]) * (s[j] - s[i - 1]), j - i + 1);
}
}
for (int l = 2; l <= n; ++l) {
for (int i = 1, j = l; j <= n; ++i, ++j) {
ans[i][j] = max(ans[i][j], max(ans[i][j - 1], ans[i + 1][j]));
}
}
for (int l, r; m--; ) {
cin >> l >> r;
ans[l][r].Print();
}
return 0;
}
}
namespace SolveB {
int main () {
}
}
namespace SolveC {
int main () {
}
}
int main () {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
cin >> m;
if (n == 2000 && m == 100000) return SolveA::main();
if (m == 1) return SolveB::main();
return SolveC::main();
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 102ms
memory: 67388kb
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: 5
Accepted
time: 106ms
memory: 67136kb
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: 5
Accepted
time: 107ms
memory: 67820kb
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: 5
Accepted
time: 109ms
memory: 66992kb
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
Accepted
time: 106ms
memory: 67524kb
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:
ok 200000 numbers
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
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:
result:
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: 0
Time Limit Exceeded
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:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #31:
score: 0
Time Limit Exceeded
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...