Submission #924533

#TimeUsernameProblemLanguageResultExecution timeMemory
92453312345678Bubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
9095 ms2392 KiB
#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=idx+1; j<N; j++) if (A[idx]>A[j]) dp[j]++; for (int j=0; j<N; j++) ans=max(ans, dp[j]); answer[i]=ans; } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...