QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#596813 | #9223. Data Determination | ucup-team1074 | TL | 317ms | 43692kb | C++23 | 2.5kb | 2024-09-28 16:30:13 | 2024-09-28 16:30:14 |
Judging History
answer
// Problem: G - Data Determination
// Contest: Virtual Judge - The 3rd Universal Cup. Stage 8: Cangqian + The 3rd Universal Cup. Stage 7: Warsaw
// URL: https://vjudge.net/contest/658753#problem/G
// Memory Limit: 1014 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
#define int long long
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
void solve()
{
int n , k , m;
cin >> n >> k >> m;
int ok = 0;
set<int>st;
int a[n];
for(int i = 0 ; i < n ; i ++){
cin >> a[i];
st.insert(a[i]);
}
map<int,int>mp;
map<int,int>pm;
int id = 0;
for(auto it : st){
mp[it] = ++id;
pm[id] = it;
}
vector<int>cnt(id + 5 , 0);
vector<int>pre(id + 5 , 0);
int b[n];
for(int i = 0 ; i < n ; i ++){
b[i] = mp[a[i]];
}
int t = mp[m];
for(int i = 0 ; i < n ; i++){
pre[b[i]]++;
cnt[b[i]]++;
}
for(int i = 1 ; i <= id ; i ++){
pre[i] += pre[i - 1];
}
if(k & 1){
int le = k / 2;
int ri = k / 2;
if(!mp.count(m)){
cout << "NIE\n";
}
else{
if(pre[mp[m] - 1] < le){
cnt[t] -= le - pre[t - 1];
}
if(pre[id] - pre[mp[m]] < ri){
cnt[t] -= ri - pre[id] + pre[t];
}
if(cnt[t] > 0){
cout <<"TAK\n";
}
else{
cout <<"NIE\n";
}
}
}
else{
int l = 1 , r = id;
while(l <= r){
while(l < r && pm[l] + pm[r] < m * 2){
l++;
}
if(pm[l] + pm[r] > m * 2){
r--;
continue;
}
else if(pm[l] + pm[r] == m * 2){
int le = k / 2 - 1;
int ri = k / 2 - 1;
int ok = 1;
if(l == r){
if( cnt[l] < 2 + max(0LL , le - pre[l - 1]) + max(0LL , ri - pre[id] + pre[r])){
ok = 0;
}
}
if(pre[l - 1] < le){
if(cnt[l] <= le - pre[l - 1]){
ok = 0;
}
}
if(pre[id] - pre[r] < ri){
if(cnt[r] <= ri - pre[id] + pre[r]){
ok = 0;
}
}
if(ok){
cout << "TAK\n";
return;
}
}
else{
r--;
}
}
cout <<"NIE\n";
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
int t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
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: 317ms
memory: 43692kb
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
Time Limit Exceeded
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...