/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 2.512 MiB
#2 Wrong Answer 35ms 2.602 MiB
#3 Wrong Answer 37ms 908.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> PII;
const ll mx = 3e5+10;

int arr[mx];
int tree[mx * 3];
void init(int node, int b, int e) {
    if(b == e) {
        tree[node] = arr[b];
        return;
    }
    int Left = node * 2;
    int Right = node * 2 + 1;
    int mid = (b + e) / 2;
    init(Left, b, mid);
    init(Right, mid + 1, e);
    tree[node] = min(tree[Left], tree[Right]);
}
int query(int node, int b, int e, int i, int j) {
    if(i > e || j < b)
        return LONG_MAX;
    if(b >= i && e <= j)
        return tree[node];
    int Left = node * 2;
    int Right = node * 2 + 1;
    int mid = (b + e) / 2;
    int p1 = query(Left, b, mid, i, j);
    int p2 = query(Right, mid + 1, e, i, j);
    return min(p1, p2);
}
void update(int node, int b, int e, int i, int newvalue) {
    if(i > e || i < b)
        return;
    if(b >= i && e <= i) {
        tree[node] = newvalue;
        return;
    }
    int Left = node * 2;
    int Right = node * 2 + 1;
    int mid = (b + e) / 2;
    update(Left, b, mid, i, newvalue);
    update(Right, mid + 1, e, i, newvalue);
    tree[node] = min(tree[Left], tree[Right]);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>> n;

    map<ll,ll> Mp;
    for(int i=1;i<=n;i++) {
        cin >> arr[i];
        Mp[arr[i]] = i;
    }
    init(1,1,n);

    int q;
    cin >> q;

    while(q--) {
        ll num;
        cin >> num;
        ll Ans = query(1,1,n, 1, n);
        cout<<Mp[Ans]<<"\n";
        update(1,1,n, Mp[Ans], num);
        Mp[Ans] = -1;
    }
}



Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 15:44:51
Judged At
2024-11-11 03:17:35
Judged By
Score
10
Total Time
37ms
Peak Memory
2.602 MiB