답안 #698241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698241 2023-02-12T23:25:59 Z Kahou Abracadabra (CEOI22_abracadabra) C++14
0 / 100
166 ms 21348 KB
/* In the name of God, aka Allah */
// Believe me - Takeshi Abo
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1050;
int n, q, a[N], b[N], out[N];
vector<pii> vc[N];

void solve() {
        cin >> n >> q;
        for (int i = 1; i <= n; i++) {
                cin >> a[i];
        }
        for (int i = 1; i <= q; i++) {
                int t, k;
                cin >> t >> k;
                t = min(t, n);
                vc[t].push_back({k, i});
        }
        for (pii x:vc[0]) out[x.S] = a[x.F];
        for (int tt = 1; tt <= n; tt++) {
                int pt = 1, p1 = 1, p2 = n/2+1;
                while (p1 <= n/2 && p2 <= n) {
                        if (a[p1] < a[p2]) b[pt++] = a[p1++];
                        else b[pt++] = a[p2++];
                }
                while (p1 <= n/2) {
                        b[pt++] = a[p1++];
                }
                while (p2 <= n) {
                        b[pt++] = a[p2++];
                }
                for (int i = 1; i <= n; i++) {
                        a[i] = b[i];
                }
                for (pii x:vc[tt]) {
                        out[x.S] = a[x.F];
                }
        }
        for (int i = 1; i <= q; i++ ){
                cout << out[i] << endl;
        }
}
int main() {
        ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        solve();
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 166 ms 21348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 166 ms 21348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -