답안 #285119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285119 2020-08-28T10:31:02 Z Pyqe Bubble Sort 2 (JOI18_bubblesort2) C++14
60 / 100
1312 ms 524292 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;

int n,ma=1e9,inf=1e9;

struct segtree
{
	int l,r,mx,lz;
	multiset<int> ms;
	segtree *p[2];
	
	void bd(int lh,int rh)
	{
		int ii;
		
		l=lh;
		r=rh;
		mx=-inf;
		lz=0;
		for(ii=0;ii<2;ii++)
		{
			p[ii]=0;
		}
	}
	void blc()
	{
		int ii,md=(l+r)/2;
		
		for(ii=0;ii<2;ii++)
		{
			if(!p[ii])
			{
				p[ii]=new segtree;
				p[ii]->bd(!ii?l:md+1,!ii?md:r);
			}
			p[ii]->mx+=lz;
			p[ii]->lz+=lz;
		}
		lz=0;
	}
	void ud(int lh,int rh,int w)
	{
		if(l>rh||r<lh);
		else if(l>=lh&&r<=rh)
		{
			mx+=w;
			lz+=w;
		}
		else
		{
			int ii;
			
			blc();
			for(ii=0;ii<2;ii++)
			{
				p[ii]->ud(lh,rh,w);
			}
			mx=max(p[0]->mx,p[1]->mx);
		}
	}
	void ins(int x,int w)
	{
		if(l>x||r<x);
		else if(l>=x&&r<=x)
		{
			ms.insert(w);
			mx=*prev(ms.end())+lz;
		}
		else
		{
			int ii;
			
			blc();
			for(ii=0;ii<2;ii++)
			{
				p[ii]->ins(x,w);
			}
			mx=max(p[0]->mx,p[1]->mx);
		}
	}
	void ers(int x,int w)
	{
		if(l>x||r<x);
		else if(l>=x&&r<=x)
		{
			ms.erase(ms.find(w));
			if(!ms.empty())
			{
				mx=*prev(ms.end())+lz;
			}
			else
			{
				mx=-inf;
			}
		}
		else
		{
			int ii;
			
			blc();
			for(ii=0;ii<2;ii++)
			{
				p[ii]->ers(x,w);
			}
			mx=max(p[0]->mx,p[1]->mx);
		}
	}
}
sg;

vector<int> countScans(vector<int> a,vector<int> qp,vector<int> qw)
{
	int t=qp.size(),rr,i,k,w;
	vector<int> sq;
	
	n=a.size();
	sg.bd(1,ma);
	for(i=0;i<n;i++)
	{
		sg.ins(a[i],i+1-n);
		sg.ud(1,a[i]-1,1);
	}
	for(rr=0;rr<t;rr++)
	{
		k=qp[rr];
		w=qw[rr];
		sg.ers(a[k],k+1-n);
		sg.ud(1,a[k]-1,-1);
		a[k]=w;
		sg.ins(w,k+1-n);
		sg.ud(1,w-1,1);
		sq.push_back(sg.mx);
	}
	return sq;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 24 ms 13312 KB Output is correct
4 Correct 24 ms 13384 KB Output is correct
5 Correct 23 ms 12800 KB Output is correct
6 Correct 23 ms 13176 KB Output is correct
7 Correct 22 ms 13176 KB Output is correct
8 Correct 23 ms 13056 KB Output is correct
9 Correct 22 ms 12800 KB Output is correct
10 Correct 19 ms 8912 KB Output is correct
11 Correct 18 ms 8960 KB Output is correct
12 Correct 18 ms 9088 KB Output is correct
13 Correct 17 ms 8320 KB Output is correct
14 Correct 17 ms 8320 KB Output is correct
15 Correct 18 ms 8320 KB Output is correct
16 Correct 16 ms 7552 KB Output is correct
17 Correct 16 ms 7416 KB Output is correct
18 Correct 16 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 24 ms 13312 KB Output is correct
4 Correct 24 ms 13384 KB Output is correct
5 Correct 23 ms 12800 KB Output is correct
6 Correct 23 ms 13176 KB Output is correct
7 Correct 22 ms 13176 KB Output is correct
8 Correct 23 ms 13056 KB Output is correct
9 Correct 22 ms 12800 KB Output is correct
10 Correct 19 ms 8912 KB Output is correct
11 Correct 18 ms 8960 KB Output is correct
12 Correct 18 ms 9088 KB Output is correct
13 Correct 17 ms 8320 KB Output is correct
14 Correct 17 ms 8320 KB Output is correct
15 Correct 18 ms 8320 KB Output is correct
16 Correct 16 ms 7552 KB Output is correct
17 Correct 16 ms 7416 KB Output is correct
18 Correct 16 ms 7424 KB Output is correct
19 Correct 81 ms 41324 KB Output is correct
20 Correct 98 ms 46456 KB Output is correct
21 Correct 109 ms 45688 KB Output is correct
22 Correct 97 ms 44792 KB Output is correct
23 Correct 80 ms 31480 KB Output is correct
24 Correct 79 ms 31480 KB Output is correct
25 Correct 68 ms 28664 KB Output is correct
26 Correct 68 ms 28664 KB Output is correct
27 Correct 63 ms 26104 KB Output is correct
28 Correct 61 ms 25976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 2128 KB Output is correct
2 Correct 133 ms 3448 KB Output is correct
3 Correct 227 ms 5112 KB Output is correct
4 Correct 209 ms 4856 KB Output is correct
5 Correct 211 ms 4856 KB Output is correct
6 Correct 213 ms 4856 KB Output is correct
7 Correct 217 ms 4856 KB Output is correct
8 Correct 226 ms 4856 KB Output is correct
9 Correct 221 ms 4856 KB Output is correct
10 Correct 195 ms 4984 KB Output is correct
11 Correct 197 ms 4984 KB Output is correct
12 Correct 198 ms 4856 KB Output is correct
13 Correct 192 ms 4856 KB Output is correct
14 Correct 190 ms 4880 KB Output is correct
15 Correct 186 ms 4856 KB Output is correct
16 Correct 180 ms 4856 KB Output is correct
17 Correct 181 ms 4856 KB Output is correct
18 Correct 181 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 11 ms 6272 KB Output is correct
3 Correct 24 ms 13312 KB Output is correct
4 Correct 24 ms 13384 KB Output is correct
5 Correct 23 ms 12800 KB Output is correct
6 Correct 23 ms 13176 KB Output is correct
7 Correct 22 ms 13176 KB Output is correct
8 Correct 23 ms 13056 KB Output is correct
9 Correct 22 ms 12800 KB Output is correct
10 Correct 19 ms 8912 KB Output is correct
11 Correct 18 ms 8960 KB Output is correct
12 Correct 18 ms 9088 KB Output is correct
13 Correct 17 ms 8320 KB Output is correct
14 Correct 17 ms 8320 KB Output is correct
15 Correct 18 ms 8320 KB Output is correct
16 Correct 16 ms 7552 KB Output is correct
17 Correct 16 ms 7416 KB Output is correct
18 Correct 16 ms 7424 KB Output is correct
19 Correct 81 ms 41324 KB Output is correct
20 Correct 98 ms 46456 KB Output is correct
21 Correct 109 ms 45688 KB Output is correct
22 Correct 97 ms 44792 KB Output is correct
23 Correct 80 ms 31480 KB Output is correct
24 Correct 79 ms 31480 KB Output is correct
25 Correct 68 ms 28664 KB Output is correct
26 Correct 68 ms 28664 KB Output is correct
27 Correct 63 ms 26104 KB Output is correct
28 Correct 61 ms 25976 KB Output is correct
29 Correct 41 ms 2128 KB Output is correct
30 Correct 133 ms 3448 KB Output is correct
31 Correct 227 ms 5112 KB Output is correct
32 Correct 209 ms 4856 KB Output is correct
33 Correct 211 ms 4856 KB Output is correct
34 Correct 213 ms 4856 KB Output is correct
35 Correct 217 ms 4856 KB Output is correct
36 Correct 226 ms 4856 KB Output is correct
37 Correct 221 ms 4856 KB Output is correct
38 Correct 195 ms 4984 KB Output is correct
39 Correct 197 ms 4984 KB Output is correct
40 Correct 198 ms 4856 KB Output is correct
41 Correct 192 ms 4856 KB Output is correct
42 Correct 190 ms 4880 KB Output is correct
43 Correct 186 ms 4856 KB Output is correct
44 Correct 180 ms 4856 KB Output is correct
45 Correct 181 ms 4856 KB Output is correct
46 Correct 181 ms 4856 KB Output is correct
47 Runtime error 1312 ms 524292 KB Execution killed with signal 9
48 Halted 0 ms 0 KB -