답안 #739626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
739626 2023-05-10T20:24:11 Z danikoynov Abracadabra (CEOI22_abracadabra) C++14
10 / 100
3000 ms 31372 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 2e5 + 10, maxq = 1e6 + 10;

int n, q, a[maxn], ans[maxq];
vector < pair < int, int > > ask[maxn];

void shuffle_array()
{
    deque < int > d1, d2;
    for (int i = 1; i <= n / 2; i ++)
        d1.push_back(a[i]);
    for (int i = n / 2 + 1; i <= n; i ++)
        d2.push_back(a[i]);

    deque < int > res;
    while(!d1.empty() && !d2.empty())
    {
        if (d1.front() < d2.front())
        {
            res.push_back(d1.front());
            d1.pop_front();
        }
        else
        {
            res.push_back(d2.front());
            d2.pop_front();
        }
    }

    while(!d1.empty())
    {
            res.push_back(d1.front());
            d1.pop_front();
    }

        while(!d2.empty())
    {
            res.push_back(d2.front());
            d2.pop_front();
    }

    for (int i = 1; i <= n; i ++)
        a[i] = res[i - 1];
}

void solve()
{
    cin >> n >> q;
    for (int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= q; i ++)
    {
        int t, v;
        cin >> t >> v;
        t = min(t, n);
        ask[t].push_back({v, i});
    }

    for (int f = 0; f <= n; f ++)
    {
        for (pair < int, int > cur : ask[f])
        {
            ans[cur.second] = a[cur.first];
        }

        /**for (int i = 1; i <= n; i ++)
            cout << a[i] << " ";
        cout << endl;*/
        shuffle_array();
    }

    for (int i = 1; i <= q; i ++)
        cout << ans[i] << endl;
}

int main()
{
    solve();
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 482 ms 23032 KB Output is correct
2 Correct 459 ms 29152 KB Output is correct
3 Correct 461 ms 28748 KB Output is correct
4 Correct 456 ms 26556 KB Output is correct
5 Correct 500 ms 30696 KB Output is correct
6 Correct 444 ms 30564 KB Output is correct
7 Correct 527 ms 31372 KB Output is correct
8 Correct 444 ms 29004 KB Output is correct
9 Correct 442 ms 28272 KB Output is correct
10 Correct 420 ms 27852 KB Output is correct
11 Correct 462 ms 28216 KB Output is correct
12 Correct 419 ms 25604 KB Output is correct
13 Correct 428 ms 26968 KB Output is correct
14 Correct 439 ms 29852 KB Output is correct
15 Correct 475 ms 27808 KB Output is correct
16 Correct 11 ms 4948 KB Output is correct
17 Correct 445 ms 25860 KB Output is correct
18 Correct 454 ms 25648 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 5004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3059 ms 14404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3071 ms 8468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 482 ms 23032 KB Output is correct
2 Correct 459 ms 29152 KB Output is correct
3 Correct 461 ms 28748 KB Output is correct
4 Correct 456 ms 26556 KB Output is correct
5 Correct 500 ms 30696 KB Output is correct
6 Correct 444 ms 30564 KB Output is correct
7 Correct 527 ms 31372 KB Output is correct
8 Correct 444 ms 29004 KB Output is correct
9 Correct 442 ms 28272 KB Output is correct
10 Correct 420 ms 27852 KB Output is correct
11 Correct 462 ms 28216 KB Output is correct
12 Correct 419 ms 25604 KB Output is correct
13 Correct 428 ms 26968 KB Output is correct
14 Correct 439 ms 29852 KB Output is correct
15 Correct 475 ms 27808 KB Output is correct
16 Correct 11 ms 4948 KB Output is correct
17 Correct 445 ms 25860 KB Output is correct
18 Correct 454 ms 25648 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 3 ms 5004 KB Output is correct
21 Execution timed out 3059 ms 14404 KB Time limit exceeded
22 Halted 0 ms 0 KB -