#include "bubblesort2.h"
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "grader.cpp"
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
// #define int long long
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)
#define FOS(i, r, l) for (int i = (r); i >= (l); --i)
#define FRN(i, n) for (int i = 0; i < (n); ++i)
#define FSN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : (x))
#define WHILE while
template<typename T> T gcd(T a, T b) { T d2 = (a | b) & -(a | b); a /= d2; b /= d2; WHILE(b) { a = a % b; swap(a, b); } return a * d2; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
void _assert(bool statement) { if (statement) return; cerr << "\n>> Assertion failed!\n"; exit(0); }
void _assert(bool statement, const str &message) { if (statement) return; cerr << "\n>> Assertion failed: " << message << '\n'; exit(0); }
void _error(const str &message) { cerr << "\n>> Error: " << message << '\n'; exit(0); }
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
END OF TEMPLATE
----------------------------------------------------------------
Tran The Bao - ghostwriter
Training for VOI23 gold medal
----------------------------------------------------------------
GOAT
----------------------------------------------------------------
*/
namespace subtask12 {
const int MAXN = 16000;
int N, Q;
vi A, X, V, d[MAXN];
bool checkCondition(vi A, vi X, vi V) {
subtask12::A = A;
subtask12::X = X;
subtask12::V = V;
return sz(A) <= 8000 && sz(X) <= 8000;
}
void compress() {
vi A1;
EACH(i, A) A1.pb(i);
EACH(i, V) A1.pb(i);
sort(all(A1));
EACH(i, A) i = lb(all(A1), i) - A1.bg();
EACH(i, V) i = lb(all(A1), i) - A1.bg();
}
int solve() {
int rs = 0, maxx = 0, num = N;
FRN(i, N) d[A[i]].pb(i);
FRN(i, MAXN) {
if (d[i].empty()) continue;
EACH(j, d[i]) {
rs = max(rs, num - N + max(maxx, j));
--num;
maxx = max(maxx, j + 1);
}
d[i].clear();
}
return rs;
}
vi countScans() {
N = sz(A);
Q = sz(X);
compress();
vi ANS(Q);
FRN(j, Q) {
A[X[j]] = V[j];
ANS[j] = solve();
}
return ANS;
}
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
if (subtask12::checkCondition(A, X, V)) return subtask12::countScans();
return vi(0, 0);
}
/*
4 2
1 2 3 4
0 3
2 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
724 KB |
Output is correct |
2 |
Correct |
26 ms |
724 KB |
Output is correct |
3 |
Correct |
90 ms |
840 KB |
Output is correct |
4 |
Correct |
94 ms |
824 KB |
Output is correct |
5 |
Correct |
93 ms |
844 KB |
Output is correct |
6 |
Correct |
73 ms |
956 KB |
Output is correct |
7 |
Correct |
75 ms |
844 KB |
Output is correct |
8 |
Correct |
78 ms |
856 KB |
Output is correct |
9 |
Correct |
98 ms |
940 KB |
Output is correct |
10 |
Correct |
73 ms |
828 KB |
Output is correct |
11 |
Correct |
76 ms |
848 KB |
Output is correct |
12 |
Correct |
75 ms |
832 KB |
Output is correct |
13 |
Correct |
77 ms |
824 KB |
Output is correct |
14 |
Correct |
83 ms |
840 KB |
Output is correct |
15 |
Correct |
74 ms |
832 KB |
Output is correct |
16 |
Correct |
85 ms |
828 KB |
Output is correct |
17 |
Correct |
78 ms |
844 KB |
Output is correct |
18 |
Correct |
104 ms |
836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
724 KB |
Output is correct |
2 |
Correct |
26 ms |
724 KB |
Output is correct |
3 |
Correct |
90 ms |
840 KB |
Output is correct |
4 |
Correct |
94 ms |
824 KB |
Output is correct |
5 |
Correct |
93 ms |
844 KB |
Output is correct |
6 |
Correct |
73 ms |
956 KB |
Output is correct |
7 |
Correct |
75 ms |
844 KB |
Output is correct |
8 |
Correct |
78 ms |
856 KB |
Output is correct |
9 |
Correct |
98 ms |
940 KB |
Output is correct |
10 |
Correct |
73 ms |
828 KB |
Output is correct |
11 |
Correct |
76 ms |
848 KB |
Output is correct |
12 |
Correct |
75 ms |
832 KB |
Output is correct |
13 |
Correct |
77 ms |
824 KB |
Output is correct |
14 |
Correct |
83 ms |
840 KB |
Output is correct |
15 |
Correct |
74 ms |
832 KB |
Output is correct |
16 |
Correct |
85 ms |
828 KB |
Output is correct |
17 |
Correct |
78 ms |
844 KB |
Output is correct |
18 |
Correct |
104 ms |
836 KB |
Output is correct |
19 |
Correct |
1112 ms |
1392 KB |
Output is correct |
20 |
Correct |
1467 ms |
1624 KB |
Output is correct |
21 |
Correct |
1147 ms |
1744 KB |
Output is correct |
22 |
Correct |
1383 ms |
1544 KB |
Output is correct |
23 |
Correct |
1093 ms |
1624 KB |
Output is correct |
24 |
Correct |
1129 ms |
1480 KB |
Output is correct |
25 |
Correct |
1134 ms |
1508 KB |
Output is correct |
26 |
Correct |
1094 ms |
1416 KB |
Output is correct |
27 |
Correct |
1061 ms |
1548 KB |
Output is correct |
28 |
Correct |
1082 ms |
1544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
724 KB |
Output is correct |
2 |
Correct |
26 ms |
724 KB |
Output is correct |
3 |
Correct |
90 ms |
840 KB |
Output is correct |
4 |
Correct |
94 ms |
824 KB |
Output is correct |
5 |
Correct |
93 ms |
844 KB |
Output is correct |
6 |
Correct |
73 ms |
956 KB |
Output is correct |
7 |
Correct |
75 ms |
844 KB |
Output is correct |
8 |
Correct |
78 ms |
856 KB |
Output is correct |
9 |
Correct |
98 ms |
940 KB |
Output is correct |
10 |
Correct |
73 ms |
828 KB |
Output is correct |
11 |
Correct |
76 ms |
848 KB |
Output is correct |
12 |
Correct |
75 ms |
832 KB |
Output is correct |
13 |
Correct |
77 ms |
824 KB |
Output is correct |
14 |
Correct |
83 ms |
840 KB |
Output is correct |
15 |
Correct |
74 ms |
832 KB |
Output is correct |
16 |
Correct |
85 ms |
828 KB |
Output is correct |
17 |
Correct |
78 ms |
844 KB |
Output is correct |
18 |
Correct |
104 ms |
836 KB |
Output is correct |
19 |
Correct |
1112 ms |
1392 KB |
Output is correct |
20 |
Correct |
1467 ms |
1624 KB |
Output is correct |
21 |
Correct |
1147 ms |
1744 KB |
Output is correct |
22 |
Correct |
1383 ms |
1544 KB |
Output is correct |
23 |
Correct |
1093 ms |
1624 KB |
Output is correct |
24 |
Correct |
1129 ms |
1480 KB |
Output is correct |
25 |
Correct |
1134 ms |
1508 KB |
Output is correct |
26 |
Correct |
1094 ms |
1416 KB |
Output is correct |
27 |
Correct |
1061 ms |
1548 KB |
Output is correct |
28 |
Correct |
1082 ms |
1544 KB |
Output is correct |
29 |
Incorrect |
3 ms |
1108 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |