QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#222162 | #7617. Spectacle | ucup-team191# | WA | 1ms | 8028kb | C++14 | 1.1kb | 2023-10-21 16:09:40 | 2023-10-21 16:09:41 |
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});
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 8028kb
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: 7972kb
input:
2 1 1000000000000000000
output:
0
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '0 '