Submission #1338150

#TimeUsernameProblemLanguageResultExecution timeMemory
1338150salmonBubble Sort Machine (JOI25_bubble)C++20
11 / 100
147 ms6848 KiB
#include <bits/stdc++.h>
using namespace std;

int N;
int lst[500100];
int Q;
long long int pre[500100];

int main(){
	
	scanf(" %d",&N);
	
	for(int i = 1; i <= N; i++){
		scanf(" %d",&lst[i]);
	}
	
	vector<pair<int,int>> v = {};
	for(int i = N; i >= 1; i--){
		while(!v.empty() && lst[i] <= v.back().first) v.pop_back();
		
		v.push_back(make_pair(lst[i],i));
	}
	
	reverse(v.begin(),v.end());
	
	int it = 0;
	int cont = 0;
	
	scanf(" %d",&Q);
	
	
	for(int i = 0; i < Q; i++){
		int T;
		
		scanf(" %d",&T);
		
		if(T == 1){
			cont++;
			
			if(it != v.size() - 1 && v[it + 1].second <= cont + 1) it++;
		}
		else{
			int l,r;
			
			scanf(" %d",&l);
			scanf(" %d",&r);
			
			
			printf("%d\n",v[it].first);
		}
	}
	
}

Compilation message (stderr)

bubble.cpp: In function 'int main()':
bubble.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
bubble.cpp:14:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                 scanf(" %d",&lst[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~
bubble.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf(" %d",&Q);
      |         ~~~~~^~~~~~~~~~
bubble.cpp:35:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |                 scanf(" %d",&T);
      |                 ~~~~~^~~~~~~~~~
bubble.cpp:45:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |                         scanf(" %d",&l);
      |                         ~~~~~^~~~~~~~~~
bubble.cpp:46:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |                         scanf(" %d",&r);
      |                         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...