This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//khodaya khodet komak kon
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-O2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 500000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;
int a[N], n, q, cnt[N];
vector<int> countScans(vi A, vi X, vi V){
n = A.size();
q = X.size();
for (int i = 1; i <= n; i++){
a[i] = A[i - 1];
}
for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++) if (a[j] > a[i]) cnt[i]++;
vector<int> res;
for (int i = 0; i < q; i++){
X[i] ++;
for (int j = X[i] + 1; j <= n; j++)if(a[X[i]] > a[j]) cnt[j]--;
// for (int j = 1; j <= n; j++) cout << cnt[
cnt[X[i]] = 0;
a[X[i]] = V[i];
for(int j = 1; j < X[i]; j++) if (a[j] > V[i]) cnt[X[i]]++;
for (int j = X[i] + 1; j <= n; j++) if (V[i] > a[j]) cnt[j]++;
int mx = 0;
for( int j = 1; j <= n; j++){
// cout << j << ' ' << cnt[j] << endl;
mx = max(mx, cnt[j]);
}
res.pb(mx);
}
return res;
}
//int32_t main(){
// vector<int> A, X, V;
// cin >> n >> q;
// for (int i = 1; i <= n; i++){
// int x;
// cin >> x;
// A.pb(x);
// }
// for (int i = 0; i < q; i++){
// int x, v;
// cin >> x >> v;
// X.pb(x);
// V.pb(v);
// }
// vi res = countScans(A, X, V);
// for (auto u:res) cout << u << '\n';
//}
# | 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... |