//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 |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
11 ms |
384 KB |
Output is correct |
3 |
Correct |
37 ms |
504 KB |
Output is correct |
4 |
Correct |
36 ms |
512 KB |
Output is correct |
5 |
Correct |
30 ms |
640 KB |
Output is correct |
6 |
Correct |
20 ms |
512 KB |
Output is correct |
7 |
Correct |
24 ms |
512 KB |
Output is correct |
8 |
Correct |
27 ms |
512 KB |
Output is correct |
9 |
Correct |
30 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
416 KB |
Output is correct |
11 |
Correct |
27 ms |
512 KB |
Output is correct |
12 |
Correct |
27 ms |
504 KB |
Output is correct |
13 |
Correct |
25 ms |
512 KB |
Output is correct |
14 |
Correct |
26 ms |
488 KB |
Output is correct |
15 |
Correct |
26 ms |
488 KB |
Output is correct |
16 |
Correct |
24 ms |
512 KB |
Output is correct |
17 |
Correct |
24 ms |
512 KB |
Output is correct |
18 |
Correct |
26 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
11 ms |
384 KB |
Output is correct |
3 |
Correct |
37 ms |
504 KB |
Output is correct |
4 |
Correct |
36 ms |
512 KB |
Output is correct |
5 |
Correct |
30 ms |
640 KB |
Output is correct |
6 |
Correct |
20 ms |
512 KB |
Output is correct |
7 |
Correct |
24 ms |
512 KB |
Output is correct |
8 |
Correct |
27 ms |
512 KB |
Output is correct |
9 |
Correct |
30 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
416 KB |
Output is correct |
11 |
Correct |
27 ms |
512 KB |
Output is correct |
12 |
Correct |
27 ms |
504 KB |
Output is correct |
13 |
Correct |
25 ms |
512 KB |
Output is correct |
14 |
Correct |
26 ms |
488 KB |
Output is correct |
15 |
Correct |
26 ms |
488 KB |
Output is correct |
16 |
Correct |
24 ms |
512 KB |
Output is correct |
17 |
Correct |
24 ms |
512 KB |
Output is correct |
18 |
Correct |
26 ms |
504 KB |
Output is correct |
19 |
Correct |
412 ms |
888 KB |
Output is correct |
20 |
Correct |
529 ms |
976 KB |
Output is correct |
21 |
Correct |
326 ms |
1016 KB |
Output is correct |
22 |
Correct |
405 ms |
888 KB |
Output is correct |
23 |
Correct |
341 ms |
888 KB |
Output is correct |
24 |
Correct |
341 ms |
1016 KB |
Output is correct |
25 |
Correct |
322 ms |
888 KB |
Output is correct |
26 |
Correct |
327 ms |
888 KB |
Output is correct |
27 |
Correct |
310 ms |
928 KB |
Output is correct |
28 |
Correct |
311 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1649 ms |
1016 KB |
Output is correct |
2 |
Correct |
8955 ms |
2148 KB |
Output is correct |
3 |
Execution timed out |
9085 ms |
2748 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
11 ms |
384 KB |
Output is correct |
3 |
Correct |
37 ms |
504 KB |
Output is correct |
4 |
Correct |
36 ms |
512 KB |
Output is correct |
5 |
Correct |
30 ms |
640 KB |
Output is correct |
6 |
Correct |
20 ms |
512 KB |
Output is correct |
7 |
Correct |
24 ms |
512 KB |
Output is correct |
8 |
Correct |
27 ms |
512 KB |
Output is correct |
9 |
Correct |
30 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
416 KB |
Output is correct |
11 |
Correct |
27 ms |
512 KB |
Output is correct |
12 |
Correct |
27 ms |
504 KB |
Output is correct |
13 |
Correct |
25 ms |
512 KB |
Output is correct |
14 |
Correct |
26 ms |
488 KB |
Output is correct |
15 |
Correct |
26 ms |
488 KB |
Output is correct |
16 |
Correct |
24 ms |
512 KB |
Output is correct |
17 |
Correct |
24 ms |
512 KB |
Output is correct |
18 |
Correct |
26 ms |
504 KB |
Output is correct |
19 |
Correct |
412 ms |
888 KB |
Output is correct |
20 |
Correct |
529 ms |
976 KB |
Output is correct |
21 |
Correct |
326 ms |
1016 KB |
Output is correct |
22 |
Correct |
405 ms |
888 KB |
Output is correct |
23 |
Correct |
341 ms |
888 KB |
Output is correct |
24 |
Correct |
341 ms |
1016 KB |
Output is correct |
25 |
Correct |
322 ms |
888 KB |
Output is correct |
26 |
Correct |
327 ms |
888 KB |
Output is correct |
27 |
Correct |
310 ms |
928 KB |
Output is correct |
28 |
Correct |
311 ms |
888 KB |
Output is correct |
29 |
Correct |
1649 ms |
1016 KB |
Output is correct |
30 |
Correct |
8955 ms |
2148 KB |
Output is correct |
31 |
Execution timed out |
9085 ms |
2748 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |