Submission #949051

# Submission time Handle Problem Language Result Execution time Memory
949051 2024-03-18T21:23:57 Z TAhmed33 Abracadabra (CEOI22_abracadabra) C++
10 / 100
1498 ms 15564 KB
#include <bits/stdc++.h>
using namespace std;
int dd[1002][1001];
int n, q;
int main () {
	cin >> n >> q;
	for (int i = 1; i <= n; i++) cin >> dd[0][i];	
	for (int i = 1; i <= n; i++) {
		deque <int> a, b;
		for (int j = 1; j <= n / 2; j++) a.push_back(dd[i - 1][j]);
		for (int j = n / 2 + 1; j <= n; j++) b.push_back(dd[i - 1][j]);
		int c = 0;
		while (!a.empty() && !b.empty()) {
			if (a.front() < b.front()) {
				dd[i][++c] = a.front(); a.pop_front();
			} else {
				dd[i][++c] = b.front(); b.pop_front();
			}
		}
		while (!a.empty()) dd[i][++c] = a.front(), a.pop_front();
		while (!b.empty()) dd[i][++c] = b.front(), b.pop_front();
	}
	while (q--) {
		int x, y; cin >> x >> y;
		x = min(x, n);
		cout << dd[x][y] << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1498 ms 8068 KB Output is correct
2 Correct 1453 ms 15564 KB Output is correct
3 Correct 1431 ms 15184 KB Output is correct
4 Correct 1378 ms 14164 KB Output is correct
5 Correct 1455 ms 15104 KB Output is correct
6 Correct 1385 ms 14160 KB Output is correct
7 Correct 1450 ms 15260 KB Output is correct
8 Correct 1430 ms 14124 KB Output is correct
9 Correct 1394 ms 14464 KB Output is correct
10 Correct 1416 ms 14172 KB Output is correct
11 Correct 1388 ms 14416 KB Output is correct
12 Correct 1382 ms 13572 KB Output is correct
13 Correct 1404 ms 14084 KB Output is correct
14 Correct 1422 ms 14872 KB Output is correct
15 Correct 1470 ms 14364 KB Output is correct
16 Correct 4 ms 4188 KB Output is correct
17 Correct 1437 ms 13564 KB Output is correct
18 Correct 1403 ms 13664 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 608 ms 10144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 331 ms 9388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1498 ms 8068 KB Output is correct
2 Correct 1453 ms 15564 KB Output is correct
3 Correct 1431 ms 15184 KB Output is correct
4 Correct 1378 ms 14164 KB Output is correct
5 Correct 1455 ms 15104 KB Output is correct
6 Correct 1385 ms 14160 KB Output is correct
7 Correct 1450 ms 15260 KB Output is correct
8 Correct 1430 ms 14124 KB Output is correct
9 Correct 1394 ms 14464 KB Output is correct
10 Correct 1416 ms 14172 KB Output is correct
11 Correct 1388 ms 14416 KB Output is correct
12 Correct 1382 ms 13572 KB Output is correct
13 Correct 1404 ms 14084 KB Output is correct
14 Correct 1422 ms 14872 KB Output is correct
15 Correct 1470 ms 14364 KB Output is correct
16 Correct 4 ms 4188 KB Output is correct
17 Correct 1437 ms 13564 KB Output is correct
18 Correct 1403 ms 13664 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Runtime error 608 ms 10144 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -