#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bug(x) cerr << #x << " : " << x << '\n'
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
int n, q;
int a[maxn];
int fen[maxn];
void add(int i){
for(; i <= n; i += i & -i)
fen[i] ++;
}
int get(int i){
int res = 0;
for(; i; i -= i & -i)
res += fen[i];
return res;
}
int solve(){
for(int i = 1; i <= n; i ++)
fen[i] = 0;
vector<pii> V;
for(int i = 0; i < n; i ++){
V.pb(mp(a[i], i + 1));
}
sort(all(V));
int ans = 0;
for(int i = n - 1; ~i; i --){
int ind = V[i].se;
ans = max(ans, get(ind));
add(ind);
}
return ans;
}
vector<int> countScans(vector<int> A, vector<int> X, vector<int> V){
n = A.size();
q = X.size();
for(int i = 0; i < n; i ++)
a[i] = A[i];
vector<int> ans;
for(int i = 0; i < q; i ++){
a[X[i]] = V[i];
ans.pb(solve());
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Correct |
50 ms |
352 KB |
Output is correct |
3 |
Correct |
318 ms |
448 KB |
Output is correct |
4 |
Correct |
328 ms |
444 KB |
Output is correct |
5 |
Correct |
310 ms |
448 KB |
Output is correct |
6 |
Correct |
227 ms |
356 KB |
Output is correct |
7 |
Correct |
269 ms |
444 KB |
Output is correct |
8 |
Correct |
302 ms |
568 KB |
Output is correct |
9 |
Correct |
304 ms |
444 KB |
Output is correct |
10 |
Correct |
210 ms |
444 KB |
Output is correct |
11 |
Correct |
209 ms |
424 KB |
Output is correct |
12 |
Correct |
217 ms |
440 KB |
Output is correct |
13 |
Correct |
212 ms |
444 KB |
Output is correct |
14 |
Correct |
225 ms |
432 KB |
Output is correct |
15 |
Correct |
218 ms |
436 KB |
Output is correct |
16 |
Correct |
204 ms |
556 KB |
Output is correct |
17 |
Correct |
211 ms |
432 KB |
Output is correct |
18 |
Correct |
206 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Correct |
50 ms |
352 KB |
Output is correct |
3 |
Correct |
318 ms |
448 KB |
Output is correct |
4 |
Correct |
328 ms |
444 KB |
Output is correct |
5 |
Correct |
310 ms |
448 KB |
Output is correct |
6 |
Correct |
227 ms |
356 KB |
Output is correct |
7 |
Correct |
269 ms |
444 KB |
Output is correct |
8 |
Correct |
302 ms |
568 KB |
Output is correct |
9 |
Correct |
304 ms |
444 KB |
Output is correct |
10 |
Correct |
210 ms |
444 KB |
Output is correct |
11 |
Correct |
209 ms |
424 KB |
Output is correct |
12 |
Correct |
217 ms |
440 KB |
Output is correct |
13 |
Correct |
212 ms |
444 KB |
Output is correct |
14 |
Correct |
225 ms |
432 KB |
Output is correct |
15 |
Correct |
218 ms |
436 KB |
Output is correct |
16 |
Correct |
204 ms |
556 KB |
Output is correct |
17 |
Correct |
211 ms |
432 KB |
Output is correct |
18 |
Correct |
206 ms |
340 KB |
Output is correct |
19 |
Correct |
4575 ms |
940 KB |
Output is correct |
20 |
Correct |
5971 ms |
996 KB |
Output is correct |
21 |
Correct |
5554 ms |
892 KB |
Output is correct |
22 |
Correct |
5968 ms |
892 KB |
Output is correct |
23 |
Correct |
3996 ms |
864 KB |
Output is correct |
24 |
Correct |
4123 ms |
868 KB |
Output is correct |
25 |
Correct |
3964 ms |
972 KB |
Output is correct |
26 |
Correct |
4059 ms |
956 KB |
Output is correct |
27 |
Correct |
3990 ms |
968 KB |
Output is correct |
28 |
Correct |
3913 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7036 ms |
1768 KB |
Output is correct |
2 |
Execution timed out |
9011 ms |
2888 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
340 KB |
Output is correct |
2 |
Correct |
50 ms |
352 KB |
Output is correct |
3 |
Correct |
318 ms |
448 KB |
Output is correct |
4 |
Correct |
328 ms |
444 KB |
Output is correct |
5 |
Correct |
310 ms |
448 KB |
Output is correct |
6 |
Correct |
227 ms |
356 KB |
Output is correct |
7 |
Correct |
269 ms |
444 KB |
Output is correct |
8 |
Correct |
302 ms |
568 KB |
Output is correct |
9 |
Correct |
304 ms |
444 KB |
Output is correct |
10 |
Correct |
210 ms |
444 KB |
Output is correct |
11 |
Correct |
209 ms |
424 KB |
Output is correct |
12 |
Correct |
217 ms |
440 KB |
Output is correct |
13 |
Correct |
212 ms |
444 KB |
Output is correct |
14 |
Correct |
225 ms |
432 KB |
Output is correct |
15 |
Correct |
218 ms |
436 KB |
Output is correct |
16 |
Correct |
204 ms |
556 KB |
Output is correct |
17 |
Correct |
211 ms |
432 KB |
Output is correct |
18 |
Correct |
206 ms |
340 KB |
Output is correct |
19 |
Correct |
4575 ms |
940 KB |
Output is correct |
20 |
Correct |
5971 ms |
996 KB |
Output is correct |
21 |
Correct |
5554 ms |
892 KB |
Output is correct |
22 |
Correct |
5968 ms |
892 KB |
Output is correct |
23 |
Correct |
3996 ms |
864 KB |
Output is correct |
24 |
Correct |
4123 ms |
868 KB |
Output is correct |
25 |
Correct |
3964 ms |
972 KB |
Output is correct |
26 |
Correct |
4059 ms |
956 KB |
Output is correct |
27 |
Correct |
3990 ms |
968 KB |
Output is correct |
28 |
Correct |
3913 ms |
980 KB |
Output is correct |
29 |
Correct |
7036 ms |
1768 KB |
Output is correct |
30 |
Execution timed out |
9011 ms |
2888 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |