UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213911#2380. 中位数WZRYWZWYCompile Error//C++2.2kb2024-11-14 18:39:342024-11-14 23:00:18

answer

#include <vector> // https://atcoder.jp/contests/abc107/submissions/12955333
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


class FenwickTree {
    public:
        FenwickTree(int n) : N(n), data(N, 0) {

        }

        void reset() {
            fill(data.begin(), data.end(), 0);
        }

        void put(int x, int v) {
            for (; x < N; x |= x + 1) {
                data[x] += v;
            }
        }

        int get(int x) {
            int res = 0;
            for (; x >= 0; x = (x & (x + 1)) - 1) {
                res += data[x];
            }
            return res;
        }

    private:
        int N;
        vector<int> data;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }


    vector<int> B(n, 0);

    int base = -n;

    FenwickTree ft(n * 2 + 123);


    long long tar = n * 1LL * (n + 1) / 2 / 2 + 1;
    // cout << tar << endl;
    auto ok = [&](int x) {
        for (int i = 0; i < n; ++i) {
            if (A[i] <= x) {
                B[i] = 1;
            } else {
                B[i] = -1;
            }
        }
        ft.reset();
        int sum = 0;
        ft.put(sum - base, 1);

        long long res = 0;
        for (auto x : B) {
            sum += x;
            res += ft.get(sum - base - 1);
            ft.put(sum - base, 1);
        }
        return res >= tar;
    };

    int mx = *max_element(A.begin(), A.end());
    long long lo = 0, hi = mx;

    while (lo < hi) {
        auto mi = (lo + hi) >> 1;
        if (ok(mi)) {
            hi = mi;
        } else {
            lo = mi + 1;
        }
    }

    cout << lo << '\n';

    return 0;
}

详细

In file included from /usr/include/c++/4.8/unordered_set:35:0,
                 from answer.code:8:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
answer.code: In function 'int main(int, char**)':
answer.code:78:10: error:...