/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
int n, q, smallsol[1000][1000], p1, p2, t, x;
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> n >> q;
if (n <= 1000){
for (int i = 0; i < n; i++) cin >> smallsol[0][i];
for (int i = 0; i < n - 1; i++){
p1 = 0;
p2 = 0;
while (p1 + p2 < n){
if (p1 == n / 2){
smallsol[i + 1][p1 + p2] = smallsol[i][n / 2 + p2];
p2++;
} else if (p2 == n / 2){
smallsol[i + 1][p1 + p2] = smallsol[i][p1];
p1++;
} else if (smallsol[i][p1] < smallsol[i][n / 2 + p2]){
smallsol[i + 1][p1 + p2] = smallsol[i][p1];
p1++;
} else {
smallsol[i + 1][p1 + p2] = smallsol[i][n / 2 + p2];
p2++;
}
}
}
while (q--){
cin >> t >> x;
cout << smallsol[min(t, n - 1)][x - 1] << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
15704 KB |
Output is correct |
2 |
Correct |
153 ms |
15424 KB |
Output is correct |
3 |
Correct |
154 ms |
15060 KB |
Output is correct |
4 |
Correct |
148 ms |
14024 KB |
Output is correct |
5 |
Correct |
160 ms |
15440 KB |
Output is correct |
6 |
Correct |
153 ms |
14280 KB |
Output is correct |
7 |
Correct |
165 ms |
15300 KB |
Output is correct |
8 |
Correct |
142 ms |
14316 KB |
Output is correct |
9 |
Correct |
140 ms |
14100 KB |
Output is correct |
10 |
Correct |
145 ms |
14168 KB |
Output is correct |
11 |
Correct |
148 ms |
14280 KB |
Output is correct |
12 |
Correct |
134 ms |
13396 KB |
Output is correct |
13 |
Correct |
155 ms |
13960 KB |
Output is correct |
14 |
Correct |
148 ms |
14856 KB |
Output is correct |
15 |
Correct |
151 ms |
14640 KB |
Output is correct |
16 |
Correct |
3 ms |
4188 KB |
Output is correct |
17 |
Correct |
137 ms |
13512 KB |
Output is correct |
18 |
Correct |
149 ms |
13588 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
15704 KB |
Output is correct |
2 |
Correct |
153 ms |
15424 KB |
Output is correct |
3 |
Correct |
154 ms |
15060 KB |
Output is correct |
4 |
Correct |
148 ms |
14024 KB |
Output is correct |
5 |
Correct |
160 ms |
15440 KB |
Output is correct |
6 |
Correct |
153 ms |
14280 KB |
Output is correct |
7 |
Correct |
165 ms |
15300 KB |
Output is correct |
8 |
Correct |
142 ms |
14316 KB |
Output is correct |
9 |
Correct |
140 ms |
14100 KB |
Output is correct |
10 |
Correct |
145 ms |
14168 KB |
Output is correct |
11 |
Correct |
148 ms |
14280 KB |
Output is correct |
12 |
Correct |
134 ms |
13396 KB |
Output is correct |
13 |
Correct |
155 ms |
13960 KB |
Output is correct |
14 |
Correct |
148 ms |
14856 KB |
Output is correct |
15 |
Correct |
151 ms |
14640 KB |
Output is correct |
16 |
Correct |
3 ms |
4188 KB |
Output is correct |
17 |
Correct |
137 ms |
13512 KB |
Output is correct |
18 |
Correct |
149 ms |
13588 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |