답안 #662268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
662268 2022-11-26T08:05:31 Z fatemetmhr Abracadabra (CEOI22_abracadabra) C++17
0 / 100
3000 ms 15868 KB
// heiy ... ye rooze jadid ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second

const int maxn5 = 1e6 + 10;
const int maxnt = 1e6 + 10;

int sum[maxnt], a[maxn5], tmp[maxn5], ans[maxn5], per[maxn5];
int rig[maxn5], sz[maxn5], t[maxn5], ind[maxn5];
bool mark[maxn5];
vector <int> av;

inline bool cmp(int i, int j){return t[i] < t[j];}

inline bool merge(int n){
    int p1 = 0, p2 = n / 2, ind = 0;
    while(ind < n){
        if(p1 < n / 2 && (p2 == n || a[p1] < a[p2]))
            tmp[ind++] = a[p1++];
        else
            tmp[ind++] = a[p2++];
    }
    bool re = true;
    for(int i = 0; i < n; i++){
        re &= (a[i] == tmp[i]);
        a[i] = tmp[i];
    }
    return re;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, q; cin >> n >> q;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < q; i++){
        cin >> t[i] >> ind[i];
        per[i] = i;
    }
    sort(per, per + q, cmp); // bar hasbe t[i]
    int done = 0;
    bool re = false;
    for(int i = 0; i < q; i++){
        while(done < t[per[i]] && !re){
            done++;
            bool re = merge(n);
        }
        ans[per[i]] = a[ind[per[i]] - 1];
    }
    for(int i = 0; i < q; i++)
        cout << ans[i] << '\n';
    
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:57:18: warning: unused variable 're' [-Wunused-variable]
   57 |             bool re = merge(n);
      |                  ^~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3098 ms 15868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3079 ms 13628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3072 ms 2668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3098 ms 15868 KB Time limit exceeded
2 Halted 0 ms 0 KB -