QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581618 | #9223. Data Determination | Displace_# | RE | 0ms | 3848kb | C++14 | 978b | 2024-09-22 13:37:24 | 2024-09-22 13:37:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N=1e5+5;
int T_,n,k,m;
int a[N];
unordered_map <int,int> mp;
bool solve(){
if(k%2==1){
int neg=0,pos=0,zer=0;
for(int i=1;i<=n;i++){
int x; cin>>x; x-=m;
if(x==0) zer++;
if(x<0) neg++;
if(x>0) pos++;
}
if(zer && min(neg,pos)>=(k-1)/2) return 1;
else return 0;
}
else{
mp.clear();
for(int i=1;i<=n;i++){
int x; cin>>x; x-=m;
a[i]=x;
}
sort(a+1,a+n+1);
for(int i=1;i<n;i++){
if(a[i]==0 && a[i+1]==0){
if(min(i,n-i)>=k/2) return 1;
}
}
for(int i=1;i<=n;i++){
if(a[i]<0){
mp[-a[i]]=i;
}
}
for(int i=1;i<=n;i++){
if(a[i]>0 && mp[a[i]]){
if(min(n-i+1,mp[a[i]])>=k/2) return 1;
}
}
return 0;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T_;
while(T_--){
cin>>n>>k>>m;
if(solve()) cout<<"TAK\n";
else cout<<"NIE\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
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: -100
Runtime Error
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...