QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#841191 | #8857. Low Power | isWFnoya | WA | 1ms | 5784kb | C++23 | 1.1kb | 2025-01-03 15:05:59 | 2025-01-03 15:05:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=2e6+10;
ll n,m,k;
ll ans;
ll a[N];
bool tf[N];
vector<PII> tg;
bool check(ll mid){
vector<PII> v;
int i=1;
while(i<m&&v.size()<n){
if(a[i+1]-a[i]<=mid){
v.push_back({i,i+1});
i++;
}
i++;
}
if(v.size()<n) return false;
reverse(v.begin(),v.end());
ll cnt=0;
for(int i=0;i<n;i++){
if(v[i].second>tg[i].first) return false;
if(v[i].first>tg[i].second) return false;
}
return true;
}
int main()
{
cin>>n>>k;
// int nn=2*n*;
m=2*n*k;
for(int i=m;i>0;){
i=i-k+1;
PII res;
res.first=i;
i--;
i=i-k+1;
res.second=i;
i--;
tg.push_back(res);
}
for(int i=1;i<=m;i++) scanf("%lld",&a[i]);
sort(a+1,a+1+m);
ll l=1,r=1e9;
while(l<r){
ll mid=l+r>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<l<<endl;
}
//51423
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5656kb
input:
2 3 1 2 3 4 5 6 7 8 9 10 11 12
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5680kb
input:
2 2 3 1 3 3 3 3 3 3
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5712kb
input:
2 3 1 2 3 4 5 6 7 8 9 10 11 12
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5728kb
input:
2 2 3 1 3 3 3 3 3 3
output:
2
result:
ok single line: '2'
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 5784kb
input:
1 1 1 1
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'