QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618765#9223. Data Determinationucup-team5062WA 71ms4836kbC++20805b2024-10-07 10:00:382024-10-07 10:00:39

Judging History

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

  • [2024-10-07 10:00:39]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:4836kb
  • [2024-10-07 10:00:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

string Solve(int N, int K, int M, vector<int> A) {
	sort(A.begin(), A.end());

	// Case #1: Odd
	if (K % 2 == 1) {
		int bar = K / 2;
		for (int i = bar; i < N - bar; i++) {
			if (A[i] != M) continue;
			return "TAK";
		}
		return "NIE";
	}

	// Case #2: Even
	for (int i = 0; i < N; i++) {
		int pos1 = lower_bound(A.begin(), A.end(), M * 2 - A[i]) - A.begin();
		if (pos1 == N || A[pos1] != M * 2 - A[i]) continue;
		int cnt = min(i + 1, N - pos1);
		if (cnt * 2 >= K) return "TAK";
	}
	return "NIE";
}

int main() {
	int T; cin >> T;
	for (int t = 1; t <= T; t++) {
		int N, K, M; cin >> N >> K >> M;
		vector<int> A(N, 0);
		for (int i = 0; i < N; i++) cin >> A[i];
		cout << Solve(N, K, M, A) << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 71ms
memory: 4836kb

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: 61ms
memory: 3692kb

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'