why?wrong on #5
查看原帖
why?wrong on #5
1001535
封禁用户楼主2024/7/9 21:11

玄关!!

#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[19000011];
set<int> b;
main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= 2 * n; ++i) {
        b.insert(i);
}
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (b.count(a[i])) {
            b.erase(a[i]);
            ans++;
        } else {
            auto it = b.begin();
            int nex = *it;
            b.erase(nex);
            ans ++;
        }
    }
    cout << ans;
    return 0;
}
2024/7/9 21:11
加载中...