QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554990#9223. Data DeterminationThe_Hallak#WA 92ms17096kbC++171.6kb2024-09-09 18:46:162024-09-09 18:46:17

Judging History

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

  • [2024-09-09 18:46:17]
  • 评测
  • 测评结果:WA
  • 用时:92ms
  • 内存:17096kb
  • [2024-09-09 18:46:16]
  • 提交

answer

#include <bits/stdc++.h>

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define YES "TAK"
#define NO "NIE"
#define endline '\n'

using namespace std;

const ll N = 5e5 + 10, MM = 998244353, MAX = 1e18;

int solve() {
  ll n,k,m;cin>>n>>k>>m;
  vector<ll>v(n);
  map<ll,ll>mp;
  for(int i=0;i<n;i++)cin>>v[i],mp[v[i]]++;
  sort(v.begin(),v.end());
  if(v.back()<m||v.front()>m)return cout<<NO<<endline,0;
  if(k%2){
    if(!mp.count(m))return cout<<NO<<endline,0;
    ll sum=0;
    for(auto x:mp){
      if(x.first==m)break;
      sum+=x.second;
    }
    ll sum1=n-mp[m]-sum;
    if(min(sum,sum1)+mp[m]-1>=k/2)cout<<YES<<endline;
    else cout<<NO<<endline;
  }else{
    v.clear();
    for(auto x:mp)v.emplace_back(x.first);
    int i=0,j=v.size()-1;
    ll sum1=0,sum2=0;
    while(v[i]<m)i++;
    while(v[j]>m)j--;
    while(i>=0&&j<v.size()){
      if(v[i]+v[j]>2*m)i--;
      else if(v[i]+v[j]<2*m)j++;
      else if(i==j&&mp[v[i]]==1)i--,j++;
      else break;
    }
    if(i<0||j>=v.size())return cout<<NO<<endline,0;
    for(int k=0;k<i;k++){
      sum1+=mp[v[k]];
    }
    for(int k=0;k<j;k++){
      sum2+=mp[v[k]];
    }
    if(i==j){
      if(min(sum2,sum1)+mp[m]-1>=k/2)cout<<YES<<endline;
      else cout<<NO<<endline;
    }else{
      sum1+=mp[v[i]];
      sum2+=mp[v[j]];
      if(sum1>=k/2&&sum2>=k/2)cout<<YES<<endline;
      else cout<<NO<<endline;
    }
  }

  return 0;
}

int main() {
	speed;
	int t = 1;
	cin >> t;
	int i = 1;
	while (t--) {
		//cout << "Case #" << i++ << ": ";
		solve();
	}
	return 0;
}
/*


*/


詳細信息

Test #1:

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

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: 92ms
memory: 17096kb

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: 54ms
memory: 4640kb

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:

NIE
TAK
TAK
TAK
TAK
NIE
NIE
NIE
NIE
NIE

result:

wrong answer 4th lines differ - expected: 'NIE', found: 'TAK'