# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548088 | 2022-04-12T11:28:26 Z | blue | Bubble Sort 2 (JOI18_bubblesort2) | C++17 | 0 ms | 0 KB |
#include "bubblesort2.h" #include <vector> #include <set> #include <map> #include <iostream> #include <algorithm> using namespace std; using vi = vector<int>; using pii = pair<int, int>; #define sz(x) int(x.size()) vi countScans(vi A, vi X, vi V) { N = sz(A); Q = sz(X); vi answer(Q); for(int j = 0; j < Q; j++) { A[X[j]] = V[j]; vector<pii> pos; for(int i = 0; i < N; i++) pos.push_back({A[i], i}); sort(pos.begin(), pos.end()); int res = 0; for(int i = 0; i < N; i++) { if(i > 0 && pos[i].first == pos[i-1].first) continue; res = max(res, pos[i].second - i); } answer[j] = res; } return answer; }