답안 #285125

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

using namespace std;

int n,ma=1e9,inf=1e9;
multiset<int> ms0;

struct segtree
{
	int l,r,mx,lz;
	vector<multiset<int>> ms;
	segtree *p[2];
	
	void bd(int lh,int rh)
	{
		int ii;
		
		l=lh;
		r=rh;
		mx=-inf;
		lz=0;
		if(l==r)
		{
			ms.push_back(ms0);
		}
		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[0].insert(w);
			mx=*prev(ms[0].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[0].erase(ms[0].find(w));
			if(!ms[0].empty())
			{
				mx=*prev(ms[0].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 6 ms 3072 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 21 ms 9600 KB Output is correct
4 Correct 21 ms 9600 KB Output is correct
5 Correct 23 ms 9384 KB Output is correct
6 Correct 21 ms 9472 KB Output is correct
7 Correct 20 ms 9472 KB Output is correct
8 Correct 20 ms 9344 KB Output is correct
9 Correct 20 ms 9216 KB Output is correct
10 Correct 16 ms 6528 KB Output is correct
11 Correct 16 ms 6528 KB Output is correct
12 Correct 16 ms 6528 KB Output is correct
13 Correct 16 ms 6016 KB Output is correct
14 Correct 16 ms 6016 KB Output is correct
15 Correct 15 ms 6016 KB Output is correct
16 Correct 14 ms 5504 KB Output is correct
17 Correct 15 ms 5504 KB Output is correct
18 Correct 15 ms 5504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 21 ms 9600 KB Output is correct
4 Correct 21 ms 9600 KB Output is correct
5 Correct 23 ms 9384 KB Output is correct
6 Correct 21 ms 9472 KB Output is correct
7 Correct 20 ms 9472 KB Output is correct
8 Correct 20 ms 9344 KB Output is correct
9 Correct 20 ms 9216 KB Output is correct
10 Correct 16 ms 6528 KB Output is correct
11 Correct 16 ms 6528 KB Output is correct
12 Correct 16 ms 6528 KB Output is correct
13 Correct 16 ms 6016 KB Output is correct
14 Correct 16 ms 6016 KB Output is correct
15 Correct 15 ms 6016 KB Output is correct
16 Correct 14 ms 5504 KB Output is correct
17 Correct 15 ms 5504 KB Output is correct
18 Correct 15 ms 5504 KB Output is correct
19 Correct 72 ms 29756 KB Output is correct
20 Correct 82 ms 33528 KB Output is correct
21 Correct 79 ms 32888 KB Output is correct
22 Correct 83 ms 32240 KB Output is correct
23 Correct 65 ms 22904 KB Output is correct
24 Correct 64 ms 22904 KB Output is correct
25 Correct 62 ms 20984 KB Output is correct
26 Correct 60 ms 20904 KB Output is correct
27 Correct 56 ms 18936 KB Output is correct
28 Correct 59 ms 18936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 2040 KB Output is correct
2 Correct 122 ms 3548 KB Output is correct
3 Correct 205 ms 4600 KB Output is correct
4 Correct 218 ms 4684 KB Output is correct
5 Correct 208 ms 4544 KB Output is correct
6 Correct 213 ms 4600 KB Output is correct
7 Correct 208 ms 4600 KB Output is correct
8 Correct 210 ms 4600 KB Output is correct
9 Correct 214 ms 4516 KB Output is correct
10 Correct 198 ms 4600 KB Output is correct
11 Correct 191 ms 4600 KB Output is correct
12 Correct 197 ms 4600 KB Output is correct
13 Correct 188 ms 4600 KB Output is correct
14 Correct 224 ms 4600 KB Output is correct
15 Correct 189 ms 4600 KB Output is correct
16 Correct 179 ms 4600 KB Output is correct
17 Correct 190 ms 4600 KB Output is correct
18 Correct 179 ms 4600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 21 ms 9600 KB Output is correct
4 Correct 21 ms 9600 KB Output is correct
5 Correct 23 ms 9384 KB Output is correct
6 Correct 21 ms 9472 KB Output is correct
7 Correct 20 ms 9472 KB Output is correct
8 Correct 20 ms 9344 KB Output is correct
9 Correct 20 ms 9216 KB Output is correct
10 Correct 16 ms 6528 KB Output is correct
11 Correct 16 ms 6528 KB Output is correct
12 Correct 16 ms 6528 KB Output is correct
13 Correct 16 ms 6016 KB Output is correct
14 Correct 16 ms 6016 KB Output is correct
15 Correct 15 ms 6016 KB Output is correct
16 Correct 14 ms 5504 KB Output is correct
17 Correct 15 ms 5504 KB Output is correct
18 Correct 15 ms 5504 KB Output is correct
19 Correct 72 ms 29756 KB Output is correct
20 Correct 82 ms 33528 KB Output is correct
21 Correct 79 ms 32888 KB Output is correct
22 Correct 83 ms 32240 KB Output is correct
23 Correct 65 ms 22904 KB Output is correct
24 Correct 64 ms 22904 KB Output is correct
25 Correct 62 ms 20984 KB Output is correct
26 Correct 60 ms 20904 KB Output is correct
27 Correct 56 ms 18936 KB Output is correct
28 Correct 59 ms 18936 KB Output is correct
29 Correct 41 ms 2040 KB Output is correct
30 Correct 122 ms 3548 KB Output is correct
31 Correct 205 ms 4600 KB Output is correct
32 Correct 218 ms 4684 KB Output is correct
33 Correct 208 ms 4544 KB Output is correct
34 Correct 213 ms 4600 KB Output is correct
35 Correct 208 ms 4600 KB Output is correct
36 Correct 210 ms 4600 KB Output is correct
37 Correct 214 ms 4516 KB Output is correct
38 Correct 198 ms 4600 KB Output is correct
39 Correct 191 ms 4600 KB Output is correct
40 Correct 197 ms 4600 KB Output is correct
41 Correct 188 ms 4600 KB Output is correct
42 Correct 224 ms 4600 KB Output is correct
43 Correct 189 ms 4600 KB Output is correct
44 Correct 179 ms 4600 KB Output is correct
45 Correct 190 ms 4600 KB Output is correct
46 Correct 179 ms 4600 KB Output is correct
47 Correct 1522 ms 458400 KB Output is correct
48 Runtime error 1501 ms 524292 KB Execution killed with signal 9
49 Halted 0 ms 0 KB -