QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#138530 | #5455. TreeScript | ammardab3an# | WA | 8ms | 3544kb | C++17 | 734b | 2023-08-11 21:43:33 | 2023-08-11 21:43:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<pair<int, int>> v(n+1);
for(int i = 0; i < n; i++){
int prev;
cin >> prev;
v[prev].second = i-1;
v[i] = {i, i};
}
vector<int> pre(n+3, 0);
for(int i = 1; i <= n; i++){
auto [f, s] = v[i];
pre[f]++;
pre[s+1]--;
}
int ans = 0;
for(int i = 1; i <= n+1; i++){
pre[i] += pre[i-1];
ans = max(ans, pre[i]);
}
cout << ans << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3432kb
input:
2 3 0 1 2 7 0 1 2 2 1 4 1
output:
1 2
result:
ok 2 number(s): "1 2"
Test #2:
score: -100
Wrong Answer
time: 8ms
memory: 3544kb
input:
1000 197 0 1 1 2 1 4 1 5 8 3 5 1 4 7 12 14 4 7 10 9 12 11 16 10 21 19 22 17 25 13 28 9 5 15 26 26 33 25 15 1 35 6 32 17 37 8 19 43 19 27 29 9 30 6 31 27 35 35 37 13 28 38 57 31 38 8 22 14 33 9 18 62 52 37 10 19 22 60 54 12 38 59 64 65 80 82 28 60 85 78 27 25 71 14 52 6 59 14 87 32 33 41 59 41 88 38 ...
output:
46 40 4 35 16 20 69 78 14 32 34 40 118 91 11 12 61 212 13 88 169 8 53 63 55 35 167 16 30 123 4 112 26 8 85 32 9 18 8 28 36 29 20 7 18 23 97 97 24 33 28 6 27 61 133 41 26 67 23 50 88 69 6 69 46 28 18 42 112 38 30 122 110 29 59 100 3 8 51 1 1 145 108 24 12 22 81 170 45 63 57 69 35 39 14 18 33 18 41 49...
result:
wrong answer 1st numbers differ - expected: '4', found: '46'