QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226021 | #7617. Spectacle | ucup-team1001# | WA | 45ms | 12496kb | C++20 | 1.3kb | 2023-10-25 14:42:25 | 2023-10-25 14:42:25 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 200099
#define irep(i,l,r) for(int i = l; i <= r; ++ i)
using namespace std;
inline ll read(){
ll s = 0, w = 1;
char ch = getchar();
while(!isdigit(ch)){
if(ch == '-')w = -1;
ch = getchar();
}
while(isdigit(ch)){
s *= 10, s+= (ch - '0');
ch = getchar();
}
return s * w;
}
int fa[N], sz[N];
int find(int x){
if(fa[x] == x)return x;
fa[x] = find(fa[x]);
return fa[x];
}
void merge(int x,int y){
//cerr << x <<' ' <<y << endl;
x = find(x), y = find(y);
sz[x] += sz[y];
sz[y] = 0;
fa[y] = x;
}
int main(){
int n = read();
vector<ll>a(n);
irep(i, 0, n - 1){
a[i] = read();
}
sort(a.begin(), a.end());
vector<array<ll, 3>>d(n - 1);
irep(i, 1, n - 1){
d[i - 1] = {a[i] - a[i - 1], i, i - 1};
}
sort(d.begin(), d.end());
vector<ll>usd(n);
int cur = 1;
set<array<ll, 2>>rg;
int ok = 0;
irep(i, 0, n - 1){
fa[i] = i, sz[i] = 1;
}
for(auto [v, p, q] : d){
ok -= sz[find(p)] / 2 - sz[find(q)] / 2;
merge(p, q);
ok += sz[find(p)] / 2;
while(cur <= n / 2 && ok >= cur){
printf("%lld ", v);
cur ++;
}
}
/*
for(auto [v, p, q] : d){
if(usd[p] == 0)sz ++;
if(usd[q] == 0)sz ++;
usd[p] = usd[q] = 1;
while(cur <= n && sz >= cur){
printf("%lld ", v);
cur += 2;
}
}
*/
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3996kb
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: 3848kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999 '
Test #3:
score: -100
Wrong Answer
time: 45ms
memory: 12496kb
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 ...
result:
wrong answer 1st lines differ - expected: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...99 9999 10000 10000 10000 10000', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 4267 4267 4267 4267 4267 4267 '