/*#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 time |
Memory |
Grader output |
1 |
Correct |
252 ms |
18188 KB |
Output is correct |
2 |
Correct |
259 ms |
18396 KB |
Output is correct |
3 |
Correct |
227 ms |
17804 KB |
Output is correct |
4 |
Correct |
200 ms |
17848 KB |
Output is correct |
5 |
Correct |
259 ms |
18328 KB |
Output is correct |
6 |
Correct |
223 ms |
17652 KB |
Output is correct |
7 |
Correct |
290 ms |
18280 KB |
Output is correct |
8 |
Correct |
193 ms |
17608 KB |
Output is correct |
9 |
Correct |
197 ms |
17960 KB |
Output is correct |
10 |
Correct |
224 ms |
17596 KB |
Output is correct |
11 |
Correct |
201 ms |
17996 KB |
Output is correct |
12 |
Correct |
223 ms |
17608 KB |
Output is correct |
13 |
Correct |
202 ms |
17744 KB |
Output is correct |
14 |
Correct |
202 ms |
18080 KB |
Output is correct |
15 |
Correct |
215 ms |
18116 KB |
Output is correct |
16 |
Correct |
14 ms |
11988 KB |
Output is correct |
17 |
Correct |
198 ms |
17692 KB |
Output is correct |
18 |
Correct |
230 ms |
17676 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
201 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
209 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
18188 KB |
Output is correct |
2 |
Correct |
259 ms |
18396 KB |
Output is correct |
3 |
Correct |
227 ms |
17804 KB |
Output is correct |
4 |
Correct |
200 ms |
17848 KB |
Output is correct |
5 |
Correct |
259 ms |
18328 KB |
Output is correct |
6 |
Correct |
223 ms |
17652 KB |
Output is correct |
7 |
Correct |
290 ms |
18280 KB |
Output is correct |
8 |
Correct |
193 ms |
17608 KB |
Output is correct |
9 |
Correct |
197 ms |
17960 KB |
Output is correct |
10 |
Correct |
224 ms |
17596 KB |
Output is correct |
11 |
Correct |
201 ms |
17996 KB |
Output is correct |
12 |
Correct |
223 ms |
17608 KB |
Output is correct |
13 |
Correct |
202 ms |
17744 KB |
Output is correct |
14 |
Correct |
202 ms |
18080 KB |
Output is correct |
15 |
Correct |
215 ms |
18116 KB |
Output is correct |
16 |
Correct |
14 ms |
11988 KB |
Output is correct |
17 |
Correct |
198 ms |
17692 KB |
Output is correct |
18 |
Correct |
230 ms |
17676 KB |
Output is correct |
19 |
Correct |
1 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Runtime error |
201 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |