/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 2.324 MiB
#2 Wrong Answer 33ms 2.844 MiB
#3 Wrong Answer 34ms 900.0 KiB
#4 Wrong Answer 36ms 2.848 MiB
#5 Accepted 150ms 10.223 MiB
#6 Accepted 153ms 11.66 MiB

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-10-03 13:30:09
Judged By
Score
50
Total Time
153ms
Peak Memory
11.66 MiB