#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> countScans(std::vector<int> a, std::vector<int> x, std::vector<int> v)
{
int n = a.size();
int q = x.size();
std::vector<int> answer(q);
for (int j = 0; j < q; j++)
{
a[x[j]] = v[j];
int mn = 1e9 + 10;
int cnt = 0;
int res = 0;
for (int i = n - 1; i >= 0; --i)
{
cnt += (int)(a[i] > mn);
if (a[i] < mn)
{
cnt = 0;
mn = a[i];
}
res = max(cnt, res);
}
answer[j] = res;
// {
// auto bf = a;
// bool good = true;
// int cur = 0;
// while (good)
// {
// good = false;
// for (int i = 0; i + 1 < n; ++i)
// if (bf[i + 1] < bf[i])
// good = true, swap(bf[i], bf[i + 1]);
// cur += good;
// }
// if (cur != res)
// {
// cout << cur << " " << res << "\n";
// for (int i = 0; i < n; ++i)
// cout << a[i] << " ";
// }
// assert(cur == cnt);
// answer[j] = cur;
// }
}
return answer;
}
// #include "bubblesort2.h"
// #include <cstdio>
// #include <cstdlib>
// #include <vector>
// int readInt()
// {
// int i;
// if (scanf("%d", &i) != 1)
// {
// fprintf(stderr, "Error while reading input\n");
// exit(1);
// }
// return i;
// }
// int main()
// {
// int N, Q;
// N = readInt();
// Q = readInt();
// std::vector<int> A(N);
// for (int i = 0; i < N; i++)
// A[i] = readInt();
// std::vector<int> X(Q), V(Q);
// for (int j = 0; j < Q; j++)
// {
// X[j] = readInt();
// V[j] = readInt();
// }
// std::vector<int> res = countScans(A, X, V);
// for (int j = 0; j < int(res.size()); j++)
// printf("%d\n", res[j]);
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |