#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=5e5+5;
int dp[nx];
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
int Q=X.size(), N=A.size();
vector<int> answer(Q);
for (int i=0; i<N; i++) for (int j=0; j<i; j++) if (A[j]>A[i]) dp[i]++;
for (int i=0; i<Q; i++) {
int idx=X[i], vl=V[i], ans=0;
for (int j=idx+1; j<N; j++) if (A[idx]>A[j]) dp[j]--;
dp[idx]=0;
A[idx]=vl;
for (int j=0; j<idx; j++) if (A[j]>A[idx]) dp[idx]++;
for (int j=0; j<N; j++) ans=max(ans, dp[j]);
answer[i]=ans;
}
return answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1214 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |