Submission #709130

#TimeUsernameProblemLanguageResultExecution timeMemory
709130vjudge1Abracadabra (CEOI22_abracadabra)C++17
10 / 100
290 ms524288 KiB
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
#define fix fixed<<setprecision
#define forn(i, n) for(int i = 1; i <= (n); ++i)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(s) (int) (s).size()
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ss second
#define ff first

using namespace std;
using namespace __gnu_pbds;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
using ll = long long;
using ull = unsigned long long;

 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main(){
	//freopen("cownomics.in", "r", stdin);
	//freopen("cownomics.out", "w", stdout);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, q;
	cin >> n >> q;
	vector<vector<int>> a(3000, vector<int>(n));
	for(int &i : a[0])
		cin >> i;
	for(int jj = 1; jj <= 2000; ++jj){
		vector<int> b = a[jj-1];
		int l = 0, r = n/2;
		vector<int> c;
		while(l < n/2 || r < n){
			if((r >= n || b[l] <= b[r]) && l < n / 2)
				c.pb(b[l++]);
			else
				c.pb(b[r++]);
		}
		a[jj] = c;
	}
	while(q--){
		int t, i;
		cin >> t >> i;
		cout << a[min(2000, t)][i-1] << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...