2 条题解

  • 0
    @ 2025-11-27 21:08:14
    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        int x,n,q;
        cin >> x >> n;
        vector<int> we(n + 1);
        vector<bool> st(n + 1, false);
        for (int i = 1; i <= n; i ++) cin >> we[i];
        cin >> q;
        while (q--) {
            int p;
            cin >> p;
            if (!st[p]) x += we[p];
            else x -= we[p];
            st[p] = !st[p];
            cout << x << '\n'; 
        }
        return 0;
    }
    
    

    信息

    ID
    5624
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    22
    已通过
    6
    上传者