#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
const int INF=0x3f3f3f3f;
const int N=8005;
int n, q;
vector <int> sol;
vector <int> saz;
int F[2*N];
int query(int x) {
int ret=0;
for (; x>0; x-=x&-x) ret+=F[x];
return ret;
}
void update(int x, int val) {
for (; x<=n+q; x+=x&-x) F[x]+=val;
}
vector<int> countScans(vector<int> A, vector<int> XX, vector<int> V){
n=A.size();
q=V.size();
saz=V;
for (int x:A) saz.pb(x);
sort(saz.begin(), saz.end());
saz.erase(unique(saz.begin(), saz.end()), saz.end());
for (int i=0; i<n; ++i) A[i]=lower_bound(saz.begin(), saz.end(), A[i])-saz.begin()+1;
for (int i=0; i<q; ++i) V[i]=lower_bound(saz.begin(), saz.end(), V[i])-saz.begin()+1;
for (int i=0; i<q; ++i) {
A[XX[i]]=V[i];
memset(F, 0, sizeof F);
int maxi=0;
for (int j=0; j<n; ++j) {
int curr=j-query(A[j]);
maxi=max(maxi, curr);
update(A[j], 1);
}
sol.pb(maxi);
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
19 ms |
636 KB |
Output is correct |
3 |
Correct |
102 ms |
620 KB |
Output is correct |
4 |
Correct |
100 ms |
492 KB |
Output is correct |
5 |
Correct |
102 ms |
492 KB |
Output is correct |
6 |
Correct |
96 ms |
492 KB |
Output is correct |
7 |
Correct |
107 ms |
492 KB |
Output is correct |
8 |
Correct |
102 ms |
876 KB |
Output is correct |
9 |
Correct |
101 ms |
492 KB |
Output is correct |
10 |
Correct |
92 ms |
492 KB |
Output is correct |
11 |
Correct |
96 ms |
620 KB |
Output is correct |
12 |
Correct |
92 ms |
620 KB |
Output is correct |
13 |
Correct |
87 ms |
492 KB |
Output is correct |
14 |
Correct |
86 ms |
492 KB |
Output is correct |
15 |
Correct |
87 ms |
492 KB |
Output is correct |
16 |
Correct |
88 ms |
620 KB |
Output is correct |
17 |
Correct |
86 ms |
492 KB |
Output is correct |
18 |
Correct |
88 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
19 ms |
636 KB |
Output is correct |
3 |
Correct |
102 ms |
620 KB |
Output is correct |
4 |
Correct |
100 ms |
492 KB |
Output is correct |
5 |
Correct |
102 ms |
492 KB |
Output is correct |
6 |
Correct |
96 ms |
492 KB |
Output is correct |
7 |
Correct |
107 ms |
492 KB |
Output is correct |
8 |
Correct |
102 ms |
876 KB |
Output is correct |
9 |
Correct |
101 ms |
492 KB |
Output is correct |
10 |
Correct |
92 ms |
492 KB |
Output is correct |
11 |
Correct |
96 ms |
620 KB |
Output is correct |
12 |
Correct |
92 ms |
620 KB |
Output is correct |
13 |
Correct |
87 ms |
492 KB |
Output is correct |
14 |
Correct |
86 ms |
492 KB |
Output is correct |
15 |
Correct |
87 ms |
492 KB |
Output is correct |
16 |
Correct |
88 ms |
620 KB |
Output is correct |
17 |
Correct |
86 ms |
492 KB |
Output is correct |
18 |
Correct |
88 ms |
620 KB |
Output is correct |
19 |
Correct |
1465 ms |
692 KB |
Output is correct |
20 |
Correct |
1835 ms |
1260 KB |
Output is correct |
21 |
Correct |
1786 ms |
1040 KB |
Output is correct |
22 |
Correct |
1822 ms |
1132 KB |
Output is correct |
23 |
Correct |
1642 ms |
1172 KB |
Output is correct |
24 |
Correct |
1608 ms |
1132 KB |
Output is correct |
25 |
Correct |
1599 ms |
1004 KB |
Output is correct |
26 |
Correct |
1584 ms |
1136 KB |
Output is correct |
27 |
Correct |
1647 ms |
1388 KB |
Output is correct |
28 |
Correct |
1632 ms |
916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1795 ms |
924 KB |
Output is correct |
2 |
Execution timed out |
9020 ms |
1516 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
364 KB |
Output is correct |
2 |
Correct |
19 ms |
636 KB |
Output is correct |
3 |
Correct |
102 ms |
620 KB |
Output is correct |
4 |
Correct |
100 ms |
492 KB |
Output is correct |
5 |
Correct |
102 ms |
492 KB |
Output is correct |
6 |
Correct |
96 ms |
492 KB |
Output is correct |
7 |
Correct |
107 ms |
492 KB |
Output is correct |
8 |
Correct |
102 ms |
876 KB |
Output is correct |
9 |
Correct |
101 ms |
492 KB |
Output is correct |
10 |
Correct |
92 ms |
492 KB |
Output is correct |
11 |
Correct |
96 ms |
620 KB |
Output is correct |
12 |
Correct |
92 ms |
620 KB |
Output is correct |
13 |
Correct |
87 ms |
492 KB |
Output is correct |
14 |
Correct |
86 ms |
492 KB |
Output is correct |
15 |
Correct |
87 ms |
492 KB |
Output is correct |
16 |
Correct |
88 ms |
620 KB |
Output is correct |
17 |
Correct |
86 ms |
492 KB |
Output is correct |
18 |
Correct |
88 ms |
620 KB |
Output is correct |
19 |
Correct |
1465 ms |
692 KB |
Output is correct |
20 |
Correct |
1835 ms |
1260 KB |
Output is correct |
21 |
Correct |
1786 ms |
1040 KB |
Output is correct |
22 |
Correct |
1822 ms |
1132 KB |
Output is correct |
23 |
Correct |
1642 ms |
1172 KB |
Output is correct |
24 |
Correct |
1608 ms |
1132 KB |
Output is correct |
25 |
Correct |
1599 ms |
1004 KB |
Output is correct |
26 |
Correct |
1584 ms |
1136 KB |
Output is correct |
27 |
Correct |
1647 ms |
1388 KB |
Output is correct |
28 |
Correct |
1632 ms |
916 KB |
Output is correct |
29 |
Correct |
1795 ms |
924 KB |
Output is correct |
30 |
Execution timed out |
9020 ms |
1516 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |