Submission #624100

# Submission time Handle Problem Language Result Execution time Memory
624100 2022-08-07T09:02:42 Z Hanksburger Simple game (IZhO17_game) C++17
0 / 100
2 ms 4180 KB
#include <bits/stdc++.h>
using namespace std;
int bit[1000005], a[100005];
void update(int x, int y)
{
    for (int i=x; i<=1e6; i+=i&(-i))
        bit[i]+=y;
}
int query(int x)
{
    int ans=0;
    for (int i=x; i; i-=i&(-i))
        ans+=bit[i];
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
    {
        cin >> a[i];
        update(a[i], 1);
    }
    for (int i=1; i<=m; i++)
    {
        int t;
        cin >> t;
        if (t==1)
        {
            int x, y;
            cin >> x >> y;
            update(a[x], -1);
            a[x]=y;
            update(a[x], 1);
        }
        else
        {
            int x;
            cin >> x;
            cout << query(x) << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -