Submission #852912

#TimeUsernameProblemLanguageResultExecution timeMemory
852912MuntherCarrotBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
3711 ms868 KiB
// 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);
	for(int i = 0; i < Q; i++){
		A[X[i]] = V[i];
		vector<int> f(N);
		iota(all(f), 0);
		sort(all(f), [&](int a, int b){
			return A[a] < A[b];
		});
		for(int j = 0; j < N; j++){
			ans[i] = max(ans[i], f[j] - j);
		}
	}
	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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...