제출 #384442

#제출 시각아이디문제언어결과실행 시간메모리
384442keko37Bubble Sort 2 (JOI18_bubblesort2)C++14
17 / 100
1022 ms1336 KiB
#include <bits/stdc++.h> #include "bubblesort2.h" using namespace std; typedef vector <int> vi; const int MAXN = 2005; int n, q; int a[MAXN], br[MAXN]; void upd (int pos, int val) { for (int i = pos + 1; i < n; i++) { if (a[pos] > a[i]) br[i]--; if (val > a[i]) br[i]++; } a[pos] = val; br[pos] = 0; for (int i = 0; i < pos; i++) { if (a[i] > a[pos]) br[pos]++; } } int solve () { int mx = 0; for (int i = 0; i < n; i++) { mx = max(mx, br[i]); } return mx; } vi countScans (vi A, vi X, vi V) { n = A.size(), q = X.size(); for (int i = 0; i < n; i++) { a[i] = A[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (a[j] > a[i]) br[i]++; } } vi sol; for (int i = 0; i < q; i++) { upd(X[i], V[i]); sol.push_back(solve()); } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...