QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#222160 | #7617. Spectacle | ucup-team191# | WA | 1ms | 3144kb | C++14 | 1.1kb | 2023-10-21 16:08:09 | 2023-10-21 16:08:09 |
Judging History
answer
#include <cstdio>
#include <vector>
#include <algorithm>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 1e6 + 500;
ll treba[N];
int n, par[N], siz[N], mogu;
vector < ll > v;
int pr(int x) {
if(par[x] == x) return x;
return par[x] = pr(par[x]);
}
void mrg(int x, int y) {
x = pr(x); y = pr(y);
if(x == y) return;
mogu -= siz[x] / 2;
mogu -= siz[y] / 2;
siz[x] += siz[y];
mogu += siz[x] / 2;
par[y] = x;
}
vector < pair < ll, int > > vp;
int main(){
scanf("%d", &n);
for(int i = 0;i < n;i++) {
ll x; scanf("%lld", &x);
v.PB(x); par[i] = i; siz[i] = 1;
treba[i] = (ll)1e18 + 500;
}
sort(v.begin(), v.end());
for(int i = 0;i + 1 < n;i++)
vp.PB({v[i + 1] - v[i], i + 1});
sort(vp.begin(), vp.end());
for(auto tmp : vp) {
mrg(tmp.Y, tmp.Y + 1);
treba[mogu] = min(treba[mogu], tmp.X);
}
for(int i = n / 2;i >= 1;i--) treba[i] = min(treba[i], treba[i + 1]);
for(int i = 1;i <= n / 2;i++) printf("%lld ", treba[i]);
printf("\n");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3132kb
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: 1ms
memory: 3144kb
input:
2 1 1000000000000000000
output:
0
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '0 '