QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#787641#9223. Data Determinationucup-team2179#WA 337ms67588kbC++231.9kb2024-11-27 13:42:202024-11-27 13:42:22

Judging History

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

  • [2024-11-27 13:42:22]
  • 评测
  • 测评结果:WA
  • 用时:337ms
  • 内存:67588kb
  • [2024-11-27 13:42:20]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define db double
#define ll long long
#define pii pair<int, int>
using namespace std;
const int maxn = 2e5 + 999;
int arr[maxn];
void solve() {
    int n, k, m;
    cin >> n >> k >> m;
    map<int, int> pre, suf, eq;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    sort(arr + 1, arr + 1 + n);
    for (int i = 1; i <= n; i++) {
        eq[arr[i]]++;
        if (i != 1 && arr[i] > arr[i - 1])
            pre[arr[i]] = pre[arr[i - 1]] + eq[arr[i - 1]];
    }
    for (int i = n; i; i--) {
        if (i != n && arr[i] < arr[i + 1])
            suf[arr[i]] = suf[arr[i + 1]] + eq[arr[i + 1]];
    }
    if (k & 1){
        if (eq[m] > 0) {
            int sml = pre[m], big = suf[m];
            int tem = min(k / 2, sml) + min(k / 2, big);
            if (tem + eq[m] >= k) {
                cout << "TAK\n";
                return;
            }
        }
    }
    else{
        for (int i = 1; i < n; i++) {
            // arr[i] + arr[j] = m * 2
            int need = m * 2 - arr[i];
            if (need == arr[i]) {
                int sml = pre[arr[i]], big = suf[arr[i]];
                int tem = min(sml, k / 2 - 1) + min(big, k / 2 - 1);
                if (tem + eq[arr[i]] >= k) {
                    cout << "TAK\n";
                    return;
                }
            } else {
                int sml = pre[arr[i]] + eq[arr[i]];
                int big = suf[need] + eq[need];
                int tem = min(sml, k / 2) + min(big, k / 2);
                if (tem >= k) {
                    cout << "TAK\n";
                    return;
                }
            }
        }
    }
    cout << "NIE\n";
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3832kb

input:

3
6 4 42
41 43 41 57 41 42
4 2 4
1 2 5 8
7 5 57
101 2 42 5 57 7 13

output:

TAK
NIE
NIE

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 337ms
memory: 67588kb

input:

1
200000 2 482043846
410684388 380438852 309193412 468460689 586281084 680820569 266819813 639025900 488292166 503516930 532292185 618277661 728546481 628339224 673945619 471325257 372807753 325778059 372151033 548358519 276494019 336701079 320784795 377493322 385262271 621712987 349634764 668994576...

output:

NIE

result:

ok single line: 'NIE'

Test #3:

score: -100
Wrong Answer
time: 116ms
memory: 9952kb

input:

10
20000 3530 502140211
367996343 553577602 581694419 435810361 532394401 431613294 485360190 608191058 506969937 531905607 429252296 360241499 519031654 250454430 478548102 753825992 450326073 603766643 566036856 511634983 416622101 753825992 753825992 380511285 390746506 436237616 342529443 878920...

output:

TAK
TAK
TAK
NIE
TAK
TAK
NIE
NIE
TAK
TAK

result:

wrong answer 1st lines differ - expected: 'NIE', found: 'TAK'