QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#315183 | #7617. Spectacle | thomas_li# | TL | 1ms | 3732kb | C++17 | 1.2kb | 2024-01-27 02:32:39 | 2024-01-27 02:32:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
#define ary(k) array<int,k>
template<class A, class B> void cmx(A& x, B y){ x = max<A>(x,y); }
template<class A, class B> void cmn(A& x, B y){ x = min<A>(x,y); }
typedef pair<int,int> pii;
typedef vector<int> vi;
signed main(){
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
int n; cin >> n;
vi a(n); for(int& v : a) cin >> v;
sort(all(a));
vi ans(n/2);
auto rec = [&](auto&& rec, int l, int r, int ql, int qr)->void{
if(ql > qr) return;
if(l == r){
rep(i,ql,qr+1) ans[i-1] = l;
return;
}
int mid = (l+r)/2;
auto f = [&](int i){
return a[i+1]-a[i] <= mid;
};
int mx = 0;
rep(i,0,n-1) if(f(i)){
int j = i;
while(j+1 < n-1 && f(j+1)) j++;
int len = j-i+1;
mx += (len+1)/2;
i = j;
}
rec(rec,l,mid,ql,min(qr,mx));
rec(rec,mid+1,r,max(mx+1,ql),qr);
};
rec(rec,0,1e18,1,n/2);
rep(i,0,n/2) cout << ans[i] << " \n"[i==n/2-1];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999'
Test #3:
score: -100
Time Limit Exceeded
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...