QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#588089 | #6528. Sequence | isirazeev | 12 | 117ms | 17108kb | C++20 | 1.4kb | 2024-09-25 00:53:45 | 2024-09-25 00:53:46 |
Judging History
answer
#include "sequence.h"
#include <vector>
#include <algorithm>
using namespace std;
const int INF = (int)1e9;
int solve(int N, vector<int> A){
int pref[N], cnt[N];
for(int i = 0; i < N; i++)
pref[i] = (A[i] == 1 ? 1 : -1) + (i > 0 ? pref[i - 1] : 0);
for(int i = 0; i < N; i++)
cnt[i] = (i > 0 ? cnt[i - 1] : 0) + (A[i] == 1);
int mx[N], res = 0;
for(int i = N - 1; i >= 0; i--)
mx[i] = max((i + 1 < N ? mx[i + 1] : -INF), pref[i]);
for(int i = N - 2; i >= -1; i--){
int at_least = (i >= 0 ? pref[i] : 0);
int l = i + 1, r = N;
while(r - l > 1){
int mid = (l + r) / 2;
if(mx[mid] >= at_least) l = mid;
else r = mid;
}
if(mx[l] >= at_least) res = max(res, cnt[l] - (i >= 0 ? cnt[i] : 0));
}
return res;
}
int sequence(int N, std::vector<int> A) {
vector<int> B = A;
sort(A.begin(), A.end());
if(A[N - 1] <= 2){
int c1 = 0, c2 = 0;
for(int i = 0; i < N; i++)
c1 += (A[i] == 1), c2 += (A[i] == 2);
return max(c1, c2);
}
vector<int> medians;
if(N % 2 == 1) medians = {A[N / 2]};
else medians = {A[N / 2 - 1], A[N / 2]};
int res = 0;
for(int x : medians){
int cnt = 0;
for(int j = 0; j < N; j++)
cnt += (A[j] == x);
res = max(res, cnt);
}
res = max(res, solve(N, B));
for(int i = 0; i < (int)B.size(); i++)
B[i] = 4 - B[i];
res = max(res, solve(N, B));
return res;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 11
Accepted
time: 0ms
memory: 3728kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 98 92 89 9 86 80 6 42 20 84 82 46 56 52 30 44 39 35 82 57 33 18 38 32 63 27 55 33 44 41 39 62 26 46 59 21 85 36 60 7 36 50 22 87 83 71 27 4 3 87 47 17 62 70 24 9 20 81 21 57 50 13 32 68 70 11 95 5 56 64 90 47 42 44 72 71 46 84 72 56 63 37 35 80 78 4 54 74 79 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 3
result:
ok
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3772kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 96 1 6 1 4 6 2 5 1 1 2 8 2 4 4 1 9 8 9 8 5 3 6 6 4 9 4 2 8 8 8 2 9 1 3 6 6 1 6 5 5 3 7 9 7 1 8 5 6 8 5 1 1 4 9 6 7 2 6 6 7 4 2 2 8 5 6 4 8 2 6 5 8 6 1 6 2 1 3 4 6 3 6 8 2 5 7 8 2 4 1 5 6 2 3 6 6
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 10
result:
wrong answer 1st lines differ - on the 1st token, expected: '18', found: '10'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #20:
score: 0
Wrong Answer
time: 98ms
memory: 16824kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 53 78 81 111 119 124 126 130 164 175 219 227 233 249 282 298 332 341 348 436 437 448 452 455 462 465 495 535 557 558 576 600 620 627 632 642 643 659 695 696 713 730 743 805 816 865 869 872 875 882 883 902 924 937 990 998 1025 1092 1137 1145 1166 1176 1...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 2
result:
wrong answer 1st lines differ - on the 1st token, expected: '8', found: '2'
Subtask #4:
score: 12
Accepted
Test #28:
score: 12
Accepted
time: 87ms
memory: 17108kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 2 1 2 2 2 1 2 3 1 3 1 2 2 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1 2 1 1 1 2 1 2 1 1 1 2 3 3 3 3 1 3 1 2 2 1 1 1 3 1 3 1 1 2 1 2 2 2 1 3 2 1 1 1 2 2 1 2 2 3 1 2 2 1 2 2 1 1 2 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 1 1 2 1 1 3 2 1 1 1 3 1 1 2 1 3 1 1 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 277713
result:
ok
Test #29:
score: 12
Accepted
time: 94ms
memory: 16824kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 2 3 1 3 3 3 1 2 3 3 3 2 2 1 1 3 1 2 1 3 3 3 2 2 2 2 3 3 2 2 2 1 1 2 3 3 1 3 1 1 2 3 3 1 1 1 2 1 1 1 2 3 2 2 1 2 1 1 3 1 1 1 3 1 1 2 1 3 2 3 1 3 1 3 3 2 1 3 1 2 1 3 2 1 1 2 3 1 2 1 3 3 1 2 1 3 3 3 2 3 2 1 1 2 1 2 3 1 1 2 2 1 3 2 3 2 3 2 2 1 3 2 3 1 3 3 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 166105
result:
ok
Test #30:
score: 12
Accepted
time: 95ms
memory: 16856kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499997 3 1 2 1 1 1 1 3 2 1 2 2 3 2 2 3 3 3 3 3 1 1 2 1 3 2 1 1 2 2 3 1 1 2 1 3 2 2 1 2 1 3 3 2 2 1 3 1 3 2 2 3 3 2 3 1 2 3 2 1 3 2 2 1 3 2 3 2 1 3 3 1 2 1 1 2 1 2 3 1 2 3 1 3 2 3 3 1 3 1 2 1 3 2 1 3 1 2 1 2 2 1 1 2 2 1 3 3 2 3 1 3 3 3 2 1 1 2 2 2 1 1 2 1 1 2 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 167067
result:
ok
Test #31:
score: 12
Accepted
time: 91ms
memory: 16824kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499996 3 2 3 3 3 1 2 3 2 2 2 2 2 2 2 3 2 2 3 1 3 1 3 2 1 2 2 3 3 3 3 1 2 1 2 2 3 2 2 2 3 3 2 2 2 1 2 2 2 3 3 2 3 3 3 3 3 2 1 3 3 2 3 3 3 3 2 2 3 3 2 1 2 2 3 3 2 3 1 1 3 2 3 2 1 3 3 2 3 3 3 1 3 2 2 3 3 2 2 3 2 3 3 2 3 3 3 2 1 1 3 3 1 2 3 3 1 3 2 3 3 3 3 3 3 2 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 277892
result:
ok
Test #32:
score: 12
Accepted
time: 82ms
memory: 16976kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 500000 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 125000
result:
ok
Subtask #5:
score: 0
Wrong Answer
Test #33:
score: 13
Accepted
time: 109ms
memory: 16900kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 490225 471440 499001 369862 494577 479599 486292 476071 471988 486939 482356 482290 497141 488452 495446 494292 404798 493826 482595 481107 447196 477441 418064 495941 448927 483365 418585 489220 443224 482574 487957 467944 493253 472016 475543 442250 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 1
result:
ok
Test #34:
score: 13
Accepted
time: 114ms
memory: 16840kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 490225 471440 499001 369862 494577 479599 486292 476071 471988 486939 482356 482290 497141 488452 495446 494292 404798 493826 482595 481107 447196 477441 418064 495941 448927 483365 418585 489220 443224 482574 487957 467944 493253 472016 475543 442250 ...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 1
result:
ok
Test #35:
score: 0
Wrong Answer
time: 117ms
memory: 17100kb
input:
8wq90di9812978rqwiok0k0o21klklm21oiwi121 499999 8693 471440 17469 369862 13045 479599 4760 476071 471988 5407 824 758 15609 6920 13914 12760 404798 12294 1063 481107 447196 477441 418064 14409 448927 1833 418585 7688 443224 1042 6425 467944 11721 472016 475543 442250 17475 477814 477933 468083 40726...
output:
nfp39szm23aa01pcmyosi03slwpeksnfjri3opqp OK 1
result:
wrong answer 1st lines differ - on the 1st token, expected: '2', found: '1'
Subtask #6:
score: 0
Skipped
Dependency #2:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%