답안 #771855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771855 2023-07-03T10:34:52 Z Dan4Life Bubble Sort 2 (JOI18_bubblesort2) C++17
100 / 100
1977 ms 41532 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using vi = vector<int>;
#define mp make_pair
#define lb lower_bound
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)1e6+5;
vi a;
vector<pair<int,int>> v;
int seg[mxN*2], lzy[mxN*2];
 
void upd(int i, int j, int vv, int p=0, int l=1, int r=sz(v)){
    if(i>r or j<l or i>j) return;
    if(i<=l and r<=j){ seg[p]+=vv,lzy[p]+=vv; return; }
    int mid = (l+r)/2; int rp = p+2*(mid-l+1);
    if(i<=mid) upd(i,j,vv,p+1,l,mid);
    if(j>mid) upd(i,j,vv,rp,mid+1,r);
    seg[p] = max(seg[p+1],seg[rp])+lzy[p];
}
 
void add(int i, int x){
    int j = lb(all(v),mp(a[i],i))-begin(v);
    int j2 = lb(all(v),mp(a[i],-1))-begin(v);
    upd(j,j,i*x), upd(j2,sz(v),-x);
}
 
vi countScans(vi A, vi x, vi y){
    int n = sz(A), q = sz(x); vi ans; a.resize(n+1);
    for(int i = 1; i <= n; i++) a[i]=A[i-1],v.pb({a[i],i});
    for(int i = 0; i < q; i++) v.pb({y[i],++x[i]});
    sort(all(v)); v.erase(unique(all(v)),end(v));
    for(int i = 1; i <= n; i++) add(i,1);
    for(int i = 0; i < q; i++)
        add(x[i],-1),a[x[i]]=y[i],add(x[i],1),ans.pb(seg[0]);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 5 ms 496 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 4 ms 476 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 456 KB Output is correct
18 Correct 5 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 5 ms 496 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 4 ms 476 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 456 KB Output is correct
18 Correct 5 ms 468 KB Output is correct
19 Correct 18 ms 972 KB Output is correct
20 Correct 14 ms 1044 KB Output is correct
21 Correct 20 ms 1032 KB Output is correct
22 Correct 14 ms 1036 KB Output is correct
23 Correct 14 ms 1016 KB Output is correct
24 Correct 13 ms 980 KB Output is correct
25 Correct 19 ms 980 KB Output is correct
26 Correct 13 ms 996 KB Output is correct
27 Correct 12 ms 992 KB Output is correct
28 Correct 18 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1468 KB Output is correct
2 Correct 56 ms 2816 KB Output is correct
3 Correct 105 ms 4536 KB Output is correct
4 Correct 101 ms 4400 KB Output is correct
5 Correct 96 ms 4452 KB Output is correct
6 Correct 109 ms 4388 KB Output is correct
7 Correct 94 ms 4376 KB Output is correct
8 Correct 93 ms 4352 KB Output is correct
9 Correct 96 ms 4376 KB Output is correct
10 Correct 74 ms 3700 KB Output is correct
11 Correct 75 ms 3732 KB Output is correct
12 Correct 78 ms 3700 KB Output is correct
13 Correct 86 ms 3696 KB Output is correct
14 Correct 74 ms 3700 KB Output is correct
15 Correct 106 ms 3692 KB Output is correct
16 Correct 97 ms 3744 KB Output is correct
17 Correct 85 ms 3708 KB Output is correct
18 Correct 75 ms 3772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 5 ms 496 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 3 ms 468 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 3 ms 468 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 4 ms 476 KB Output is correct
15 Correct 4 ms 468 KB Output is correct
16 Correct 3 ms 468 KB Output is correct
17 Correct 3 ms 456 KB Output is correct
18 Correct 5 ms 468 KB Output is correct
19 Correct 18 ms 972 KB Output is correct
20 Correct 14 ms 1044 KB Output is correct
21 Correct 20 ms 1032 KB Output is correct
22 Correct 14 ms 1036 KB Output is correct
23 Correct 14 ms 1016 KB Output is correct
24 Correct 13 ms 980 KB Output is correct
25 Correct 19 ms 980 KB Output is correct
26 Correct 13 ms 996 KB Output is correct
27 Correct 12 ms 992 KB Output is correct
28 Correct 18 ms 972 KB Output is correct
29 Correct 19 ms 1468 KB Output is correct
30 Correct 56 ms 2816 KB Output is correct
31 Correct 105 ms 4536 KB Output is correct
32 Correct 101 ms 4400 KB Output is correct
33 Correct 96 ms 4452 KB Output is correct
34 Correct 109 ms 4388 KB Output is correct
35 Correct 94 ms 4376 KB Output is correct
36 Correct 93 ms 4352 KB Output is correct
37 Correct 96 ms 4376 KB Output is correct
38 Correct 74 ms 3700 KB Output is correct
39 Correct 75 ms 3732 KB Output is correct
40 Correct 78 ms 3700 KB Output is correct
41 Correct 86 ms 3696 KB Output is correct
42 Correct 74 ms 3700 KB Output is correct
43 Correct 106 ms 3692 KB Output is correct
44 Correct 97 ms 3744 KB Output is correct
45 Correct 85 ms 3708 KB Output is correct
46 Correct 75 ms 3772 KB Output is correct
47 Correct 378 ms 12900 KB Output is correct
48 Correct 1641 ms 38148 KB Output is correct
49 Correct 1786 ms 41424 KB Output is correct
50 Correct 1977 ms 41456 KB Output is correct
51 Correct 1711 ms 41400 KB Output is correct
52 Correct 1812 ms 41396 KB Output is correct
53 Correct 1823 ms 41532 KB Output is correct
54 Correct 1946 ms 41416 KB Output is correct
55 Correct 1678 ms 41412 KB Output is correct
56 Correct 1545 ms 41452 KB Output is correct
57 Correct 1723 ms 41384 KB Output is correct
58 Correct 1611 ms 41512 KB Output is correct
59 Correct 1427 ms 39572 KB Output is correct
60 Correct 1504 ms 39496 KB Output is correct
61 Correct 1534 ms 39452 KB Output is correct
62 Correct 1434 ms 38560 KB Output is correct
63 Correct 1314 ms 38508 KB Output is correct
64 Correct 1343 ms 38480 KB Output is correct
65 Correct 1237 ms 37588 KB Output is correct
66 Correct 1239 ms 37616 KB Output is correct
67 Correct 1253 ms 37500 KB Output is correct