QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#699485 | #9223. Data Determination | Rico64 | Compile Error | / | / | C++23 | 1.5kb | 2024-11-02 09:19:52 | 2024-11-02 09:19:52 |
Judging History
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;
}
Details
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