Submission #821793

# Submission time Handle Problem Language Result Execution time Memory
821793 2023-08-11T16:49:08 Z AdamGS Bubble Sort 2 (JOI18_bubblesort2) C++17
100 / 100
3773 ms 113372 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
int T[LIM], tr[8*LIM], lazy[8*LIM], N=1;
vector<pair<int,int>>skal;
map<pair<int,int>,int>mp;
pair<int,int>pyt[LIM];
void spl(int v) {
  tr[2*v]+=lazy[v];
  tr[2*v+1]+=lazy[v];
  lazy[2*v]+=lazy[v];
  lazy[2*v+1]+=lazy[v];
  lazy[v]=0;
}
void upd(int v, int l, int r, int a, int b, int x) {
  if(r<a || l>b) return;
  if(a<=l && r<=b) {
    tr[v]+=x;
    lazy[v]+=x;
    return;
  }
  if(lazy[v]) spl(v);
  int mid=(l+r)/2;
  upd(2*v, l, mid, a, b, x);
  upd(2*v+1, mid+1, r, a, b, x);
  tr[v]=max(tr[2*v], tr[2*v+1]);
}
vector<int>countScans(vector<int>A, vector<int>X, vector<int>V) {
  int n=A.size(), q=X.size();
  rep(i, n) skal.pb({A[i], i});
  rep(i, q) skal.pb({V[i], X[i]});
  sort(all(skal));
  int akt=0;
  for(auto i : skal) if(mp.find(i)==mp.end()) mp[i]=akt++;
  while(N<akt) N*=2;
  rep(i, n) {
    int p=mp[{A[i], i}];
    upd(1, 0, N-1, p, p, i);
    upd(1, 0, N-1, p+1, N-1, -1);
  }
  vector<int>ans(q);
  rep(i, q) {
    int p=mp[{A[X[i]], X[i]}];
    upd(1, 0, N-1, p, p, -X[i]);
    upd(1, 0, N-1, p+1, N-1, 1);
    A[X[i]]=V[i];
    p=mp[{A[X[i]], X[i]}];
    upd(1, 0, N-1, p, p, X[i]);
    upd(1, 0, N-1, p+1, N-1, -1);
    ans[i]=tr[1];
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 6 ms 724 KB Output is correct
15 Correct 4 ms 716 KB Output is correct
16 Correct 4 ms 688 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 6 ms 724 KB Output is correct
15 Correct 4 ms 716 KB Output is correct
16 Correct 4 ms 688 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 16 ms 1956 KB Output is correct
20 Correct 18 ms 2148 KB Output is correct
21 Correct 17 ms 2124 KB Output is correct
22 Correct 17 ms 2128 KB Output is correct
23 Correct 16 ms 1864 KB Output is correct
24 Correct 16 ms 1996 KB Output is correct
25 Correct 15 ms 1880 KB Output is correct
26 Correct 16 ms 1888 KB Output is correct
27 Correct 15 ms 1748 KB Output is correct
28 Correct 15 ms 1736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3240 KB Output is correct
2 Correct 84 ms 6864 KB Output is correct
3 Correct 172 ms 10884 KB Output is correct
4 Correct 145 ms 10788 KB Output is correct
5 Correct 156 ms 10736 KB Output is correct
6 Correct 147 ms 10688 KB Output is correct
7 Correct 165 ms 10636 KB Output is correct
8 Correct 139 ms 10684 KB Output is correct
9 Correct 145 ms 10720 KB Output is correct
10 Correct 124 ms 7312 KB Output is correct
11 Correct 108 ms 7400 KB Output is correct
12 Correct 97 ms 7292 KB Output is correct
13 Correct 96 ms 7408 KB Output is correct
14 Correct 100 ms 7328 KB Output is correct
15 Correct 120 ms 7440 KB Output is correct
16 Correct 93 ms 7552 KB Output is correct
17 Correct 111 ms 7416 KB Output is correct
18 Correct 103 ms 7392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 4 ms 724 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 4 ms 724 KB Output is correct
12 Correct 4 ms 640 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 6 ms 724 KB Output is correct
15 Correct 4 ms 716 KB Output is correct
16 Correct 4 ms 688 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 3 ms 696 KB Output is correct
19 Correct 16 ms 1956 KB Output is correct
20 Correct 18 ms 2148 KB Output is correct
21 Correct 17 ms 2124 KB Output is correct
22 Correct 17 ms 2128 KB Output is correct
23 Correct 16 ms 1864 KB Output is correct
24 Correct 16 ms 1996 KB Output is correct
25 Correct 15 ms 1880 KB Output is correct
26 Correct 16 ms 1888 KB Output is correct
27 Correct 15 ms 1748 KB Output is correct
28 Correct 15 ms 1736 KB Output is correct
29 Correct 26 ms 3240 KB Output is correct
30 Correct 84 ms 6864 KB Output is correct
31 Correct 172 ms 10884 KB Output is correct
32 Correct 145 ms 10788 KB Output is correct
33 Correct 156 ms 10736 KB Output is correct
34 Correct 147 ms 10688 KB Output is correct
35 Correct 165 ms 10636 KB Output is correct
36 Correct 139 ms 10684 KB Output is correct
37 Correct 145 ms 10720 KB Output is correct
38 Correct 124 ms 7312 KB Output is correct
39 Correct 108 ms 7400 KB Output is correct
40 Correct 97 ms 7292 KB Output is correct
41 Correct 96 ms 7408 KB Output is correct
42 Correct 100 ms 7328 KB Output is correct
43 Correct 120 ms 7440 KB Output is correct
44 Correct 93 ms 7552 KB Output is correct
45 Correct 111 ms 7416 KB Output is correct
46 Correct 103 ms 7392 KB Output is correct
47 Correct 823 ms 33684 KB Output is correct
48 Correct 3527 ms 103620 KB Output is correct
49 Correct 3773 ms 113100 KB Output is correct
50 Correct 3643 ms 113068 KB Output is correct
51 Correct 3644 ms 113104 KB Output is correct
52 Correct 3511 ms 113068 KB Output is correct
53 Correct 3656 ms 113100 KB Output is correct
54 Correct 3528 ms 113372 KB Output is correct
55 Correct 3514 ms 113284 KB Output is correct
56 Correct 3135 ms 113252 KB Output is correct
57 Correct 3314 ms 113336 KB Output is correct
58 Correct 3078 ms 113240 KB Output is correct
59 Correct 2652 ms 102156 KB Output is correct
60 Correct 2654 ms 102164 KB Output is correct
61 Correct 2638 ms 102024 KB Output is correct
62 Correct 2526 ms 97172 KB Output is correct
63 Correct 2547 ms 97124 KB Output is correct
64 Correct 2541 ms 97136 KB Output is correct
65 Correct 2195 ms 92092 KB Output is correct
66 Correct 2165 ms 91984 KB Output is correct
67 Correct 2209 ms 92092 KB Output is correct