QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#369064 | #7617. Spectacle | Delay_for_five_minutes# | WA | 1ms | 3844kb | C++20 | 1.6kb | 2024-03-27 20:09:04 | 2024-03-27 20:09:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
ll r[200005];
vector<ll> a,b;
ll ans[100005];
void solve(const vector<ll>& v) {
vector<int> p(v.size()) , siz(v.size()) , vis(v.size());
for(int i = 0;i < p.size();i++) p[i] =i , siz[i] = 1;
auto Find = [&](int x,auto self)->int {
if(p[x] == x) return x;
return p[x] = self(p[x] , self) ;
};
vector<pair<ll,int> > v2;
for(int i = 0;i < v.size();i++) v2.push_back({v[i] , i}) ;
sort(v2.begin() , v2.end()) ;
int ttl = 0;
for(int i = 0;i < v2.size();i++) {
int id = v2[i].second ;
vis[id] = 1;
if(id > 0 && vis[id - 1]) {
int a = Find(id - 1 , Find) ;
ttl -= (siz[a] + 1) / 2;
p[a] = id ; siz[id] += siz[a] ;
}
if(id < v.size() - 1 && vis[id + 1]) {
int a = Find(id + 1 , Find) ;
ttl -= (siz[a] + 1) / 2;
p[a] = id ; siz[id] += siz[a] ;
}
ttl += (siz[id] + 1) / 2;
ans[ttl] = min(ans[ttl] , v2[i].first);
// printf("T %d %lld : %lld\n",ttl,v2[i].first , ans[ttl]) ;
}
for(int i = n/2; i >= 1;i--) {
ans[i] = min(ans[i] , ans[i + 1]) ;
}
}
int main() {
ios::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
cin >> n;
for(int i = 1;i <= n;i++) cin >> r[i];
sort(r + 1, r + n + 1) ;
for(int i = 2;i <= n;i++) {
a.push_back(r[i] - r[i - 1]) ;
// printf("%lld\n",r[i] - r[i - 1]) ;
}
for(int i = 1;i <= n/2 + 1;i++) ans[i] = 1e9;
solve(a) ;
for(int i = 1;i <= n/2;i++) cout << ans[i] <<' ' ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6 '
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
2 1 1000000000000000000
output:
1000000000
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '1000000000 '