#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], b[maxn];
int solve(){
vector<pii> V;
for(int i = 0; i < n; i ++){
V.pb(mp(a[i], i));
}
sort(all(V));
for(int i = 1; i <= n; i ++){
b[V[i - 1].se] = i;
}
set<int> S;
S.insert(n + 1);
int ans = 0;
for(int i = n - 1; ~i; i --){
auto it = S.lower_bound(b[i]);
ans = max(ans, (*it) - b[i]);
S.insert(b[i]);
}
return ans - 1;
}
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9095 ms |
2396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
57 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |