QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748903 | #7617. Spectacle | shstyle# | WA | 65ms | 39564kb | C++23 | 1.4kb | 2024-11-14 21:53:49 | 2024-11-14 21:53:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n;
ll a[N],b[N];
int p[N],sz[N];
bool tf[N];
vector<PII> v;
vector<ll> v2;
ll tot;
ll ans[N];
int find(int x){
if(p[x]!=x) p[x]=find(p[x]);
return p[x];
}
bool merge(int x,int y){
if(!tf[x]||!tf[y]) return false;
int fx=find(x),fy=find(y);
tot-=(sz[fx]+1)/2;
tot-=(sz[fy]+1)/2;
sz[fx]+=sz[fy];
p[fy]=fx;
tot+=(sz[fx]+1)/2;
return true;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
sort(a+1,a+1+n);
for(int i=1;i<n;i++) b[i]=a[i+1]-a[i];
for(int i=1;i<=n;i++) p[i]=i,sz[i]=1;
for(int i=1;i<n;i++){
// cout<<b[i]<<endl;
v.push_back({b[i],i});
v2.push_back(b[i]);
}
memset(ans,0x3f,sizeof ans);
sort(v.begin(),v.end());
sort(v2.begin(),v2.end());
int j=0;
for(int i=0;i<v2.size();i++){
while(j<v.size()&&v[j].first<=v2[i]){
// cout<<j<<endl;
// tf[j]=1;
bool flag=0;
int id=v[j].second;
tf[id]=1;
tot++;
if(merge(id,id+1)) flag=1;
if(merge(id-1,id)) flag=1;
// if(!flag) tot++;
j++;
}
// cout<<tot<<endl;
ans[tot]=min(ans[tot],v2[i]);
}
for(int i=1;i<=n/2;i++) printf("%lld ",ans[i]);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 27096kb
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: 4ms
memory: 27016kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999 '
Test #3:
score: -100
Wrong Answer
time: 65ms
memory: 39564kb
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...
output:
4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 4557430888798830399 ...
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: '4557430888798830399 4557430888...0399 4557430888798830399 10000 '