#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();
for (int i=0; i<N; i++) dp[i]=0;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1194 ms |
788 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |