Submission #852922

# Submission time Handle Problem Language Result Execution time Memory
852922 2023-09-23T07:34:24 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
22 / 100
66 ms 4312 KB
// by me
#include "bubblesort2.h"

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V){
	int Q = X.size();
	int N = A.size();
	vector<int> ans(Q, 0);
	vector<set<int>> f(101);
	for(int i = 0; i < N; i++){
		f[A[i]].insert(i);
	}
	for(int i = 0; i < Q; i++){
		f[A[X[i]]].erase(X[i]);
		A[X[i]] = V[i];
		f[A[X[i]]].insert(X[i]);
		int x = 0;
		for(auto &st : f){
			if(st.empty()) continue;
			x += st.size();
			int mx = *st.rbegin();
			ans[i] = max(ans[i], mx - x + 1);
		}
	}
	return ans;
}

//
/*
int readInt(){
	int i;
	if(scanf("%d",&i)!=1){
		fprintf(stderr,"Error while reading input\n");
		exit(1);
	}
	return i;
}

int main(){
	int N,Q;
	N=readInt();
	Q=readInt();

	std::vector<int> A(N);
	for(int i=0;i<N;i++)
		A[i]=readInt();

	std::vector<int> X(Q),V(Q);
	for(int j=0;j<Q;j++){
		X[j]=readInt();
		V[j]=readInt();
	}

	std::vector<int> res=countScans(A,X,V);

	for(int j=0;j<int(res.size());j++)
		printf("%d\n",res[j]);
}
//*/
// by me
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1880 KB Output is correct
2 Correct 29 ms 2996 KB Output is correct
3 Correct 52 ms 3928 KB Output is correct
4 Correct 54 ms 3928 KB Output is correct
5 Correct 56 ms 3928 KB Output is correct
6 Correct 53 ms 3932 KB Output is correct
7 Correct 66 ms 4312 KB Output is correct
8 Correct 54 ms 4148 KB Output is correct
9 Correct 58 ms 3928 KB Output is correct
10 Correct 49 ms 3928 KB Output is correct
11 Correct 48 ms 4096 KB Output is correct
12 Correct 49 ms 4104 KB Output is correct
13 Correct 43 ms 3920 KB Output is correct
14 Correct 48 ms 3920 KB Output is correct
15 Correct 43 ms 4104 KB Output is correct
16 Correct 55 ms 3928 KB Output is correct
17 Correct 54 ms 3948 KB Output is correct
18 Correct 54 ms 4112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -