// KCPC - 50.6907
#include <bits/stdc++.h>
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define rs(v) v << 1 | 1, md + 1, r
#define ls(v) v << 1, l, md
#define md ((l + r) >> 1)
#define pb emplace_back
#define elif else if
#define uns unsigned
#define emp empty()
#define nll nullptr
#define S second
#define F first
#define int long long
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef pair < int, int > pi;
typedef pair < ldb, ldb > pldb;
typedef vector < pair < ll, ll > > vpll;
typedef vector < pair < int, int > > vpi;
const int N = 1e6 + 11;
const int M = 1e3 + 123;
const int mod = 1e9 + 7;
const int mxlg = 19;
const int K = 20;
const int P = 31;
const ll inf = 1e9 + 10;
//mt19937 rnd(07062006);
int n, q;
int a[N], t[N], k[N];
void output(){
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= q; i++) cin >> t[i] >> k[i];
if(n <= 1000){
int s[1003][1003];
for(int i = 0; i <= n; i++){
memset(s[i], 0, sizeof(s[i]));
s[0][i] = a[i];
s[i][n + 1] = inf;
}
for(int i = 1; i <= n; i++){
int i1 = 1, i2 = n / 2 + 1, id = 1;
while(id <= n){
if(s[i - 1][i1] <= s[i - 1][i2] && i1 <= n / 2) s[i][id] = s[i - 1][i1], i1++;
else if(i2 <= n) s[i][id] = s[i - 1][i2], i2++;
else s[i][id] = s[i - 1][i1], i1++;
id++;
}
}
for(int i = 1; i <= q; i++){
if(t[i] > n) t[i] = n;
cout << s[t[i]][k[i]] << '\n';
}
}
}
const bool cases = 0;
signed main(){
// file("disrupt");
adiyer();
int tt = 1;
if(cases) cin >> tt;
for(int i = 1; i <= tt; i++){
// cout << "Case " << i << ":\n";
output();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
159 ms |
36316 KB |
Output is correct |
2 |
Correct |
155 ms |
36172 KB |
Output is correct |
3 |
Correct |
157 ms |
36000 KB |
Output is correct |
4 |
Correct |
140 ms |
34640 KB |
Output is correct |
5 |
Correct |
185 ms |
35764 KB |
Output is correct |
6 |
Correct |
142 ms |
35000 KB |
Output is correct |
7 |
Correct |
157 ms |
35900 KB |
Output is correct |
8 |
Correct |
142 ms |
34876 KB |
Output is correct |
9 |
Correct |
156 ms |
34752 KB |
Output is correct |
10 |
Correct |
151 ms |
35156 KB |
Output is correct |
11 |
Correct |
140 ms |
34900 KB |
Output is correct |
12 |
Correct |
140 ms |
34060 KB |
Output is correct |
13 |
Correct |
146 ms |
34628 KB |
Output is correct |
14 |
Correct |
146 ms |
35300 KB |
Output is correct |
15 |
Correct |
149 ms |
35156 KB |
Output is correct |
16 |
Correct |
6 ms |
12380 KB |
Output is correct |
17 |
Correct |
145 ms |
34236 KB |
Output is correct |
18 |
Correct |
138 ms |
34244 KB |
Output is correct |
19 |
Correct |
4 ms |
12380 KB |
Output is correct |
20 |
Correct |
4 ms |
12300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
144 ms |
41148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
159 ms |
36316 KB |
Output is correct |
2 |
Correct |
155 ms |
36172 KB |
Output is correct |
3 |
Correct |
157 ms |
36000 KB |
Output is correct |
4 |
Correct |
140 ms |
34640 KB |
Output is correct |
5 |
Correct |
185 ms |
35764 KB |
Output is correct |
6 |
Correct |
142 ms |
35000 KB |
Output is correct |
7 |
Correct |
157 ms |
35900 KB |
Output is correct |
8 |
Correct |
142 ms |
34876 KB |
Output is correct |
9 |
Correct |
156 ms |
34752 KB |
Output is correct |
10 |
Correct |
151 ms |
35156 KB |
Output is correct |
11 |
Correct |
140 ms |
34900 KB |
Output is correct |
12 |
Correct |
140 ms |
34060 KB |
Output is correct |
13 |
Correct |
146 ms |
34628 KB |
Output is correct |
14 |
Correct |
146 ms |
35300 KB |
Output is correct |
15 |
Correct |
149 ms |
35156 KB |
Output is correct |
16 |
Correct |
6 ms |
12380 KB |
Output is correct |
17 |
Correct |
145 ms |
34236 KB |
Output is correct |
18 |
Correct |
138 ms |
34244 KB |
Output is correct |
19 |
Correct |
4 ms |
12380 KB |
Output is correct |
20 |
Correct |
4 ms |
12300 KB |
Output is correct |
21 |
Incorrect |
144 ms |
41148 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |