QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#362757 | #3276. 出题高手 | Slongod | 0 | 906ms | 9800kb | C++14 | 1.7kb | 2024-03-23 17:01:13 | 2024-03-23 17:01:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace Slongod{
constexpr int N = 1e5+7 , B = 300;
int n , m , a[N] , bl[N];
struct frac{
int a , b;
frac(){a = 0; b = 1;} frac(int x , int y){a = x; b = y;}
bool operator < (const frac&x) const{return 1ll * a * x.b < 1ll * x.a * b;}
}ans[N] , now[N] , tag[N];
vector <pair<int,int>> p[N];
void main()
{
cin >> n; for (int i = 1; i <= n; i++){cin >> a[i]; bl[i] = (i - 1) / B + 1;}
cin >> m; for (int i = 1 , l , r; i <= m; i++){cin >> l >> r; p[r].push_back({l , i});}
for (int i = 1; i <= n; i++) {
for (int j = i , sum = a[i]; j >= 1 and j >= i - 2000; j-- , sum += a[j]) {
now[j] = max(now[j] , frac(abs(sum) * abs(sum) , i - j + 1));
tag[bl[j]] = max(tag[bl[j]] , now[j]);
}
for (auto o : p[i]) {
if (bl[i] == bl[o.first]) {
for (int j = o.first; j <= i; j++) {
ans[o.second] = max(ans[o.second] , now[j]);
}
} else {
for (int j = o.first; bl[j] == bl[o.first]; j++) {
ans[o.second] = max(ans[o.second] , now[j]);
}
for (int j = bl[o.first] + 1; j < bl[i]; j++) {
ans[o.second] = max(ans[o.second] , tag[j]);
}
for (int j = i; bl[j] == bl[i]; j--) {
ans[o.second] = max(ans[o.second] , now[j]);
}
}
}
}
for (int i = 1; i <= m; i++) {
cout << ans[i].a << ' ' << ans[i].b << '\n';
}
}
}int main()
{
ios :: sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
return Slongod :: main(),0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 30ms
memory: 9800kb
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:
164480625 33 14638276 7 4743684 4 81018001 24 6310144 3 12545764 5 67240000 20 23068809 8 23068809 8 12545764 5 4334724 3 5424241 3 3250809 3 8561476 4 2752281 2 24760576 8 3003289 2 19838116 8 17106496 13 38241856 8 89605156 31 8543929 4 129163225 48 20376196 8 68591524 23 8543929 4 35688676 11 604...
result:
wrong answer 1st numbers differ - expected: '54826875', found: '164480625'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 15
Accepted
time: 888ms
memory: 9028kb
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: -15
Wrong Answer
time: 906ms
memory: 9044kb
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:
369062521 61
result:
wrong answer 1st numbers differ - expected: '2417885584', found: '369062521'
Subtask #3:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
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
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 890ms
memory: 9284kb
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 41873841 12 67914081 16 66487716 14 21771556 6 27836176 7 50680161 11 235284921 74 106770889 25 2411809 2 14175225 5 56070144 20 134699236 43 286523329 74 28100601 11 35093776 10 23396569 6 242518329 75 4012009 3 15968016 6 85895824 22 38217124 11 61496964 19 18361225 5 6120676 3 7573...
result:
wrong answer 3rd numbers differ - expected: '13957947', found: '41873841'
Subtask #5:
score: 0
Runtime Error
Test #31:
score: 0
Runtime Error
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...