QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#221931 | #7617. Spectacle | ucup-team061# | WA | 1ms | 3620kb | C++17 | 3.1kb | 2023-10-21 15:05:23 | 2023-10-21 15:05:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using ll = long long;
const int N = 2e5 + 5, inf = 0x3fffffff, mod = 998244353;
const long long INF = 0x3fffffffffffffff;
int n, a[N], p[N], sz[N], vis[N];
int ans[N];
int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
void merge(int x, int y)
{
x = find(x), y = find(y);
sz[x] += sz[y];
p[y] = x;
}
// int brans[N];
// int b[N];
// void br()
// {
// // static int b[N];
// for(int i = 1; i < n; i++){
// b[i-1] = a[i+1]-a[i];
// brans[i] = INF;
// }
// int m = n-1;
// for(int st = 0; st < (1<<m); st++){
// int flag = 1, cnt = 0, mx = 0;
// for(int i = 0; i < m; i++){
// if((st>>i&1) && (st>>(i+1)&1)){
// flag = 0;
// }
// cnt += (st>>i&1);
// if(st>>i&1){
// mx = max(mx, b[i]);
// }
// }
// if(!flag)continue;
// brans[cnt] = min(brans[cnt], mx);
// }
// cerr << "asdddd";
// for(int i = 1; i <= (n/2); i++){
// cerr << ans[i] << " \n"[i==n/2];
// }
// cerr << "qweeee";
// for(int i = 1; i <= (n/2); i++){
// cerr << brans[i] << " \n"[i==n/2];
// }
// cerr << "zxcccc";
// // cerr << n << ' ' << n/2 << '\n';
// for(int i = 1; (i <= n/2); i++){
// // if(i>n){
// // cerr << (i>n) << "\n";
// // }
// // cerr << "diff = " << i << ' ' << n << ' ' << (i<=n) << '\n';
// assert(brans[i] == ans[i]);
// }
// return;
// }
mt19937 rnd(time(0));
signed main() {
#ifdef stdjudge
freopen("/home/stdforces/code/contest/in.txt", "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
// memset(vis, 0, sizeof(vis));
cin >> n;
// n = 25;
for(int i = 1; i <= n; i++){
cin >> a[i];
// a[i] = rnd()%100+1;
// cerr << a[i] << " \n"[i==n];
}
sort(a+1, a+1+n);
vector<pair<int,int> > v;
for(int i = 2; i <= n; i++){
v.push_back({a[i]-a[i-1], i-1});
}
int m = n-1;
for(int i = 1; i <= m; i++){
p[i] = i;
sz[i] = 1;
ans[i] = INF;
}
sort(v.begin(), v.end());
int num = 0;
for(auto [val, id]:v){
// cerr << val << ' ' << id << '\n';
vis[id] = 1;
num++;
if(id>1 && vis[id-1]){
num -= (sz[find(id-1)]+1)/2;
num -= (sz[find(id)]+1)/2;
merge(id, id-1);
num += (sz[find(id)]+1)/2;
}
if(id < m && vis[id+1]){
num -= (sz[find(id+1)]+1)/2;
num -= (sz[find(id)]+1)/2;
merge(id, id+1);
num += (sz[find(id)]+1)/2;
}
ans[num] = min(ans[num], val);
}
for(int i = n/2; i>= 1; i--)
ans[i] = min(ans[i], ans[i+1]);
for(int i = 1; i <= n/2; i++){
cout << ans[i] << " ";
}
cout << "\n";
// br();
// main();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3568kb
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: 3620kb
input:
2 1 1000000000000000000
output:
0
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '0 '