Submission #851947

# Submission time Handle Problem Language Result Execution time Memory
851947 2023-09-20T21:22:18 Z MrM7md Bubble Sort 2 (JOI18_bubblesort2) C++17
60 / 100
3437 ms 9520 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
// #define int long long
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=2e5 + 3;
const int MOD=1e9+7;
const int off=(1<<20);
 
// int mx[off*2],mn[off*2];
// void upd(int x,int v){
// 	x+=off;
// 	mx[x]=v;
// 	mn[x]=v;
// 	while(x/=2){
// 		mx[x]=max(mx[x*2],mx[x*2+1]);
// 		if(mn[x*2]==0)mn[x*2]=INT_MAX;
// 		if(mn[x*2+1]==0)mn[x*2+1]=INT_MAX;
// 		mn[x]=min(mn[x*2],mn[x*2+1]);
// 	}
// }
// int get(int x,int l,int r,int st,int en,int val){
// 	if(r<st||l>en)return 0;
//    if(l>=st&&r<=en){
//       // if(mn[x]>val)
//       return r-l+1;
//       // if(mx[x]<=val)
//       return 0;
//    }
//    int mid=(l+r)/2;
//    return (get(x*2,l,mid,st,en,val)+get(x*2+1,mid+1,r,st,en,val));
// }
 
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){

	vector<int>ans;
	int q=X.size(),n=A.size();
	if(n>=8001||q>=8001){
		vector<set<int>>vv(101);
		for(int i=0;i<n;i++){
			vv[A[i]].insert(i+1);
		}
		for(int j=0;j<q;j++){
			int x=X[j],v=V[j];
			vv[A[x]].erase(x+1);
			vv[v].insert(x+1);
			A[x]=v;
			int cur=0,mxx=0;
			for(int i=1;i<=100;i++){
				if(vv[i].empty())continue;
				cur+=vv[i].size();
				mxx=max(mxx,(*vv[i].rbegin())-cur);
			}
			ans.pb(mxx);
		}
		return ans;
	}
	// int dis[n]={0};
	multiset<int>ms;
	vector<pair<int,int>>per,yo;
	for(int i=0;i<n;i++)per.pb({A[i],i});
   for(int j=0;j<q;j++){
      int x=X[j],v=V[j];
		A[x]=v;
		per[x]={v,x};
		yo=per;
		sort(all(yo));
		int mxx=0;
 		for(int i=0;i<n;i++){
			mxx=max(mxx,yo[i].S-i);
		}
		
      ans.pb(mxx);
   }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 27 ms 472 KB Output is correct
3 Correct 188 ms 500 KB Output is correct
4 Correct 180 ms 500 KB Output is correct
5 Correct 174 ms 504 KB Output is correct
6 Correct 108 ms 500 KB Output is correct
7 Correct 148 ms 764 KB Output is correct
8 Correct 170 ms 348 KB Output is correct
9 Correct 176 ms 508 KB Output is correct
10 Correct 101 ms 500 KB Output is correct
11 Correct 100 ms 348 KB Output is correct
12 Correct 102 ms 348 KB Output is correct
13 Correct 101 ms 500 KB Output is correct
14 Correct 101 ms 504 KB Output is correct
15 Correct 99 ms 348 KB Output is correct
16 Correct 92 ms 348 KB Output is correct
17 Correct 93 ms 500 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 27 ms 472 KB Output is correct
3 Correct 188 ms 500 KB Output is correct
4 Correct 180 ms 500 KB Output is correct
5 Correct 174 ms 504 KB Output is correct
6 Correct 108 ms 500 KB Output is correct
7 Correct 148 ms 764 KB Output is correct
8 Correct 170 ms 348 KB Output is correct
9 Correct 176 ms 508 KB Output is correct
10 Correct 101 ms 500 KB Output is correct
11 Correct 100 ms 348 KB Output is correct
12 Correct 102 ms 348 KB Output is correct
13 Correct 101 ms 500 KB Output is correct
14 Correct 101 ms 504 KB Output is correct
15 Correct 99 ms 348 KB Output is correct
16 Correct 92 ms 348 KB Output is correct
17 Correct 93 ms 500 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
19 Correct 2614 ms 1208 KB Output is correct
20 Correct 3437 ms 784 KB Output is correct
21 Correct 2923 ms 784 KB Output is correct
22 Correct 3281 ms 788 KB Output is correct
23 Correct 1937 ms 788 KB Output is correct
24 Correct 1940 ms 792 KB Output is correct
25 Correct 1912 ms 784 KB Output is correct
26 Correct 1921 ms 792 KB Output is correct
27 Correct 1907 ms 796 KB Output is correct
28 Correct 1914 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1884 KB Output is correct
2 Correct 30 ms 3124 KB Output is correct
3 Correct 52 ms 4688 KB Output is correct
4 Correct 51 ms 4692 KB Output is correct
5 Correct 53 ms 4764 KB Output is correct
6 Correct 52 ms 4692 KB Output is correct
7 Correct 51 ms 4692 KB Output is correct
8 Correct 52 ms 4768 KB Output is correct
9 Correct 52 ms 4832 KB Output is correct
10 Correct 46 ms 4744 KB Output is correct
11 Correct 46 ms 4808 KB Output is correct
12 Correct 44 ms 4728 KB Output is correct
13 Correct 41 ms 4688 KB Output is correct
14 Correct 46 ms 4692 KB Output is correct
15 Correct 40 ms 4688 KB Output is correct
16 Correct 43 ms 4924 KB Output is correct
17 Correct 36 ms 4692 KB Output is correct
18 Correct 36 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 348 KB Output is correct
2 Correct 27 ms 472 KB Output is correct
3 Correct 188 ms 500 KB Output is correct
4 Correct 180 ms 500 KB Output is correct
5 Correct 174 ms 504 KB Output is correct
6 Correct 108 ms 500 KB Output is correct
7 Correct 148 ms 764 KB Output is correct
8 Correct 170 ms 348 KB Output is correct
9 Correct 176 ms 508 KB Output is correct
10 Correct 101 ms 500 KB Output is correct
11 Correct 100 ms 348 KB Output is correct
12 Correct 102 ms 348 KB Output is correct
13 Correct 101 ms 500 KB Output is correct
14 Correct 101 ms 504 KB Output is correct
15 Correct 99 ms 348 KB Output is correct
16 Correct 92 ms 348 KB Output is correct
17 Correct 93 ms 500 KB Output is correct
18 Correct 86 ms 344 KB Output is correct
19 Correct 2614 ms 1208 KB Output is correct
20 Correct 3437 ms 784 KB Output is correct
21 Correct 2923 ms 784 KB Output is correct
22 Correct 3281 ms 788 KB Output is correct
23 Correct 1937 ms 788 KB Output is correct
24 Correct 1940 ms 792 KB Output is correct
25 Correct 1912 ms 784 KB Output is correct
26 Correct 1921 ms 792 KB Output is correct
27 Correct 1907 ms 796 KB Output is correct
28 Correct 1914 ms 784 KB Output is correct
29 Correct 8 ms 1884 KB Output is correct
30 Correct 30 ms 3124 KB Output is correct
31 Correct 52 ms 4688 KB Output is correct
32 Correct 51 ms 4692 KB Output is correct
33 Correct 53 ms 4764 KB Output is correct
34 Correct 52 ms 4692 KB Output is correct
35 Correct 51 ms 4692 KB Output is correct
36 Correct 52 ms 4768 KB Output is correct
37 Correct 52 ms 4832 KB Output is correct
38 Correct 46 ms 4744 KB Output is correct
39 Correct 46 ms 4808 KB Output is correct
40 Correct 44 ms 4728 KB Output is correct
41 Correct 41 ms 4688 KB Output is correct
42 Correct 46 ms 4692 KB Output is correct
43 Correct 40 ms 4688 KB Output is correct
44 Correct 43 ms 4924 KB Output is correct
45 Correct 36 ms 4692 KB Output is correct
46 Correct 36 ms 4696 KB Output is correct
47 Runtime error 41 ms 9520 KB Execution killed with signal 11
48 Halted 0 ms 0 KB -