답안 #925061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925061 2024-02-10T15:59:44 Z ttamx Bubble Sort 2 (JOI18_bubblesort2) C++14
60 / 100
9000 ms 13500 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>

using namespace std;

using pi = pair<int,int>;

struct Segtree{
	int n;
	vector<int> t,lz;
	Segtree(int _n){
		n=_n;
		int s=4<<(31-__builtin_clz(n));
		t.assign(s,0);
		lz.assign(s,0);
	}
	void push(int l,int r,int i){
		t[i]+=lz[i];
		if(l<r){
			lz[i*2]+=lz[i];
			lz[i*2+1]+=lz[i];
		}
		lz[i]=0;
	}
	void update(int l,int r,int i,int x,int y,int v){
		push(l,r,i);
		if(y<l||r<x)return;
		if(x<=l&&r<=y)return lz[i]=v,push(l,r,i);
		int m=(l+r)/2;
		update(l,m,i*2,x,y,v);
		update(m+1,r,i*2+1,x,y,v);
		t[i]=max(t[i*2],t[i*2+1]);
	}
	void update(int x,int y,int v){
		update(0,n-1,1,x,y,v);
	}
};

vector<int> countScans(vector<int> a,vector<int> x,vector<int> v){
	int n=a.size();
	int q=x.size();
	vector<int> ans(q);
	vector<pi> vec;
	for(int i=0;i<n;i++)vec.emplace_back(a[i],i);
	for(int i=0;i<q;i++)vec.emplace_back(v[i],x[i]);
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++)a[i]=find(vec.begin(),vec.end(),pi(a[i],i))-vec.begin();
	for(int i=0;i<q;i++)v[i]=find(vec.begin(),vec.end(),pi(v[i],x[i]))-vec.begin();
	Segtree s(n+q);
	auto upd=[&](int i,int v){
		s.update(a[i],a[i],i*v);
		s.update(a[i]+1,n+q,-v);
	};
	for(int i=0;i<n;i++)upd(i,1);
	for(int i=0;i<q;i++){
		upd(x[i],-1);
		a[x[i]]=v[i];
		upd(x[i],1);
		ans[i]=s.t[1];
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
4 Correct 6 ms 604 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 6 ms 604 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 6 ms 604 KB Output is correct
9 Correct 7 ms 488 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 7 ms 600 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 8 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
4 Correct 6 ms 604 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 6 ms 604 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 6 ms 604 KB Output is correct
9 Correct 7 ms 488 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 7 ms 600 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 8 ms 604 KB Output is correct
19 Correct 49 ms 1356 KB Output is correct
20 Correct 72 ms 1224 KB Output is correct
21 Correct 61 ms 1112 KB Output is correct
22 Correct 63 ms 1080 KB Output is correct
23 Correct 54 ms 1076 KB Output is correct
24 Correct 66 ms 1108 KB Output is correct
25 Correct 54 ms 1104 KB Output is correct
26 Correct 52 ms 1104 KB Output is correct
27 Correct 65 ms 1072 KB Output is correct
28 Correct 55 ms 1052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 199 ms 1496 KB Output is correct
2 Correct 873 ms 3184 KB Output is correct
3 Correct 2059 ms 5328 KB Output is correct
4 Correct 2087 ms 5336 KB Output is correct
5 Correct 2050 ms 5768 KB Output is correct
6 Correct 2052 ms 5340 KB Output is correct
7 Correct 2043 ms 5340 KB Output is correct
8 Correct 2082 ms 5344 KB Output is correct
9 Correct 2096 ms 5356 KB Output is correct
10 Correct 2872 ms 5424 KB Output is correct
11 Correct 2763 ms 5412 KB Output is correct
12 Correct 2957 ms 5672 KB Output is correct
13 Correct 2420 ms 5584 KB Output is correct
14 Correct 2463 ms 5408 KB Output is correct
15 Correct 2488 ms 5320 KB Output is correct
16 Correct 2129 ms 5400 KB Output is correct
17 Correct 2314 ms 5408 KB Output is correct
18 Correct 2366 ms 5392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 8 ms 604 KB Output is correct
4 Correct 6 ms 604 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 6 ms 604 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 6 ms 604 KB Output is correct
9 Correct 7 ms 488 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 7 ms 600 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 8 ms 604 KB Output is correct
19 Correct 49 ms 1356 KB Output is correct
20 Correct 72 ms 1224 KB Output is correct
21 Correct 61 ms 1112 KB Output is correct
22 Correct 63 ms 1080 KB Output is correct
23 Correct 54 ms 1076 KB Output is correct
24 Correct 66 ms 1108 KB Output is correct
25 Correct 54 ms 1104 KB Output is correct
26 Correct 52 ms 1104 KB Output is correct
27 Correct 65 ms 1072 KB Output is correct
28 Correct 55 ms 1052 KB Output is correct
29 Correct 199 ms 1496 KB Output is correct
30 Correct 873 ms 3184 KB Output is correct
31 Correct 2059 ms 5328 KB Output is correct
32 Correct 2087 ms 5336 KB Output is correct
33 Correct 2050 ms 5768 KB Output is correct
34 Correct 2052 ms 5340 KB Output is correct
35 Correct 2043 ms 5340 KB Output is correct
36 Correct 2082 ms 5344 KB Output is correct
37 Correct 2096 ms 5356 KB Output is correct
38 Correct 2872 ms 5424 KB Output is correct
39 Correct 2763 ms 5412 KB Output is correct
40 Correct 2957 ms 5672 KB Output is correct
41 Correct 2420 ms 5584 KB Output is correct
42 Correct 2463 ms 5408 KB Output is correct
43 Correct 2488 ms 5320 KB Output is correct
44 Correct 2129 ms 5400 KB Output is correct
45 Correct 2314 ms 5408 KB Output is correct
46 Correct 2366 ms 5392 KB Output is correct
47 Execution timed out 9081 ms 13500 KB Time limit exceeded
48 Halted 0 ms 0 KB -