QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#699485#9223. Data DeterminationRico64Compile Error//C++231.5kb2024-11-02 09:19:522024-11-02 09:19:52

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 09:19:52]
  • 评测
  • [2024-11-02 09:19:52]
  • 提交

answer

#include <iostream>

using namespace std;

bool solve() {
    int n, k;
    long long m;
    cin >> n >> k >> m;
    long long arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    sort(arr, arr + n);
    if (k % 2 == 1) {
        int lm = 0, mm = 0, rm = 0;
        for (int i = 0; i < n; ++i) lm += arr[i] < m;
        for (int i = 0; i < n; ++i) mm += arr[i] == m;
        for (int i = 0; i < n; ++i) rm += arr[i] > m;
        mm -= max(k / 2 - lm, 0);
        mm -= max(k / 2 - rm, 0);
        return mm >= 1;
    } else {
        int c = -1;
        {
            int l = 0, r = n, mm;
            while (l < r) {
                mm = (l + r) / 2;
                if (arr[mm] <= m) {
                    l = mm + 1;
                    c = mm;
                } else {
                    r = mm;
                }
            }
            if (c == -1 || c == n - 1) return false;
        }
        int l = c, r = c + 1;
        while (l >= 0 && r < n) {
            if (arr[l] + arr[r] == m * 2) {
                int lm = l + 1, rm = n - r;
                return lm >= k / 2 && rm >= k / 2;
            } else if (arr[l] + arr[r] < m * 2) {
                r++;
            } else {
                l--;
            }
        }
        return false;
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        if (solve()) {
            cout << "TAK" << endl;
        } else {
            cout << "NIE" << endl;
        }
    }

    return 0;
}

詳細信息

answer.code: In function ‘bool solve()’:
answer.code:11:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   11 |     sort(arr, arr + n);
      |     ^~~~
      |     short