题解:AT_abc448_c [ABC448C] Except and Min
Charged_Charge · · 题解
思路:
这题可以用 multiset 直接模拟解决。对于删除操作,直接在 multiset 中查找球 multiset 自带的 .begin() 实现查找最小值,最后把所有的球 multiset 即可。
AC 代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e5 + 10;
int n, q;
int a[N], b[N];
multiset<int> st;
signed main() {
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
st.insert(a[i]);
}
while (q--) {
int k;
cin >> k;
for (int i = 1; i <= k; i++) {
cin >> b[i];
st.erase(st.find(a[b[i]]));
}
cout << *st.begin() << '\n';
for (int i = 1; i <= k; i++) {
st.insert(a[b[i]]);
}
}
return 0;
}