답안 #769324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769324 2023-06-29T12:16:24 Z Dan4Life Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
9000 ms 1876 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using vi = vector<int>;
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2e4+10;
int fen[mxN];
void upd(int x, int v){
	for(; x<mxN; x+=x&-x) fen[x]+=v;
}

int sum(int x){ int s = 0; for(; x>0; x-=x&-x) s+=fen[x]; return s; }
int sum(int a, int b){
	if(a>b) return 0;
	return sum(b)-sum(a-1);
}

vi countScans(vi A, vi X, vi V){
    int q = sz(X), n = sz(A); vi ans, a(all(A));
	vector<int> v; 
	for(auto u : a) v.pb(u);
	for(int i = 0; i < q; i++) v.pb(V[i]);
	sort(all(v)); v.erase(unique(all(v)),end(v));
	for(int i = 0; i < q; i++) V[i]=(int)(lower_bound(all(v),V[i])-begin(v))+1;
	for(int i = 0; i < n; i++) a[i]=(int)(lower_bound(all(v),a[i])-begin(v))+1;
    for(int _ = 0; _ < q; _++){
        a[X[_]] = V[_];
        int tot = 0; fill(fen,fen+mxN,0);
        for(int i = 0; i < n; i++){
            tot = max(tot, sum(a[i]+1,mxN-1));
			upd(a[i],1);
        }
        ans.pb(tot);
    }
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 15 ms 436 KB Output is correct
3 Correct 91 ms 488 KB Output is correct
4 Correct 92 ms 448 KB Output is correct
5 Correct 97 ms 508 KB Output is correct
6 Correct 84 ms 500 KB Output is correct
7 Correct 87 ms 492 KB Output is correct
8 Correct 104 ms 468 KB Output is correct
9 Correct 90 ms 468 KB Output is correct
10 Correct 79 ms 500 KB Output is correct
11 Correct 75 ms 488 KB Output is correct
12 Correct 74 ms 468 KB Output is correct
13 Correct 72 ms 480 KB Output is correct
14 Correct 73 ms 468 KB Output is correct
15 Correct 72 ms 484 KB Output is correct
16 Correct 82 ms 480 KB Output is correct
17 Correct 75 ms 484 KB Output is correct
18 Correct 73 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 15 ms 436 KB Output is correct
3 Correct 91 ms 488 KB Output is correct
4 Correct 92 ms 448 KB Output is correct
5 Correct 97 ms 508 KB Output is correct
6 Correct 84 ms 500 KB Output is correct
7 Correct 87 ms 492 KB Output is correct
8 Correct 104 ms 468 KB Output is correct
9 Correct 90 ms 468 KB Output is correct
10 Correct 79 ms 500 KB Output is correct
11 Correct 75 ms 488 KB Output is correct
12 Correct 74 ms 468 KB Output is correct
13 Correct 72 ms 480 KB Output is correct
14 Correct 73 ms 468 KB Output is correct
15 Correct 72 ms 484 KB Output is correct
16 Correct 82 ms 480 KB Output is correct
17 Correct 75 ms 484 KB Output is correct
18 Correct 73 ms 492 KB Output is correct
19 Correct 1348 ms 852 KB Output is correct
20 Correct 1727 ms 896 KB Output is correct
21 Correct 1689 ms 900 KB Output is correct
22 Correct 1715 ms 896 KB Output is correct
23 Correct 1361 ms 876 KB Output is correct
24 Correct 1374 ms 884 KB Output is correct
25 Correct 1365 ms 868 KB Output is correct
26 Correct 1366 ms 876 KB Output is correct
27 Correct 1336 ms 868 KB Output is correct
28 Correct 1333 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1588 ms 1024 KB Output is correct
2 Execution timed out 9053 ms 1876 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 15 ms 436 KB Output is correct
3 Correct 91 ms 488 KB Output is correct
4 Correct 92 ms 448 KB Output is correct
5 Correct 97 ms 508 KB Output is correct
6 Correct 84 ms 500 KB Output is correct
7 Correct 87 ms 492 KB Output is correct
8 Correct 104 ms 468 KB Output is correct
9 Correct 90 ms 468 KB Output is correct
10 Correct 79 ms 500 KB Output is correct
11 Correct 75 ms 488 KB Output is correct
12 Correct 74 ms 468 KB Output is correct
13 Correct 72 ms 480 KB Output is correct
14 Correct 73 ms 468 KB Output is correct
15 Correct 72 ms 484 KB Output is correct
16 Correct 82 ms 480 KB Output is correct
17 Correct 75 ms 484 KB Output is correct
18 Correct 73 ms 492 KB Output is correct
19 Correct 1348 ms 852 KB Output is correct
20 Correct 1727 ms 896 KB Output is correct
21 Correct 1689 ms 900 KB Output is correct
22 Correct 1715 ms 896 KB Output is correct
23 Correct 1361 ms 876 KB Output is correct
24 Correct 1374 ms 884 KB Output is correct
25 Correct 1365 ms 868 KB Output is correct
26 Correct 1366 ms 876 KB Output is correct
27 Correct 1336 ms 868 KB Output is correct
28 Correct 1333 ms 860 KB Output is correct
29 Correct 1588 ms 1024 KB Output is correct
30 Execution timed out 9053 ms 1876 KB Time limit exceeded
31 Halted 0 ms 0 KB -