QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#219413 | #7617. Spectacle | ucup-team1447# | WA | 1ms | 6068kb | C++23 | 3.6kb | 2023-10-19 14:27:44 | 2023-10-19 14:27:44 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <stdio.h>
#include <array>
#include <random>
#include <queue>
std::mt19937_64 rng(0x3d03d);
#include <math.h>
#include <time.h>
#include <assert.h>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#define ld(x) printf("%lld\n",x)
#define int long long
const int mod=1e9+7;
using std::vector;
using vi=vector<int>;
using pi=std::pair<int,int>;
using vpi=vector<pi>;
#define x first
#define y second
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a<b?b:a;}
inline int read()
{
int num=0,f=1;char c=getchar();
while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
while(c>47&&c<58)num=num*10+(c^48),c=getchar();
return num*f;
}
typedef int arr[1000005];
arr a,b;
struct qwq{
vi a,b,c,d;
};
const int inf=1e18;
void check(vi a)
{
for(int i=2;i<a.size();i++)
{
if(a[i-1]*2<a[i]+a[i-2])
{
for(int t:a)printf("%lld ",t>=0?t:-1);
puts("");
exit(0);
}
}
}
vi operator+(vi a,vi b)
{
// check(a);
// check(b);
// assert(a.size());
// assert(b.size());
int x=0,y=0;
vi c(a.size()+b.size()-1,-1e18);
c[0]=max(a[0],b[0]);
for(int i=1;i<c.size();i++)
{
if(x==a.size()-1)y++;
else if(y==b.size()-1)x++;
else
{
if(a[x+1]<b[y+1])x++;
else y++;
}
c[i]=max(a[x],b[y]);
}
// while(c.size()&&c.back()==-1e18)c.pop_back();
return c;
}
vi max(vi a,vi b)
{
if(a.size()<b.size())a.swap(b);
for(int i=0;i<b.size();i++)a[i]=min(a[i],b[i]);
// vi c(max(a.size(),b.size()),-1e18);
// for(int i=0;i<a.size();i++)c[i]=max(c[i],a[i]);
// for(int i=0;i<b.size();i++)c[i]=max(c[i],b[i]);
// while(c.size()&&c.back()==-1e18)c.pop_back();
return a;
}
qwq solve(int l,int r)
{
if(l==r)
{
return {{0},{0},{0},{0,b[l]}};
// return {{-inf,0},{-inf,0},{-inf,0},{-inf,b[l]}};
// return {{-inf,b[l]},{-inf,0},{-inf,0},{-inf,0}};
}
int m=l+r>>1;
auto [a00,a01,a10,a11]=solve(l,m);
auto [b00,b01,b10,b11]=solve(m+1,r);
qwq qwqwq={
max( max(a00+b00,a01+b00) , (a00+b10 )) ,
max( max(a00+b01,a01+b01) , (a00+b11 )) ,
max( max(a10+b00,a11+b00) , (a10+b10 )) ,
max( max(a10+b01,a11+b01) , (a10+b11 ))
// max(max(a00,b00),max(pop(a00+b00),max(pop(a01+b10),max(a00+b10,a01+b00)))),
// max(max(a00,b01),max(pop(a00+b01),max(pop(a01+b11),max(a00+b11,a01+b01)))),
// max(max(a10,b00),max(pop(a10+b00),max(pop(a11+b10),max(a10+b10,a11+b00)))),
// max(max(a10,b01),max(pop(a10+b01),max(pop(a11+b11),max(a10+b11,a11+b01))))
};
// printf("[%d %d] :%d %d %d %d\n",l,r,qwqwq.a.size(),qwqwq.b.size(),qwqwq.c.size(),qwqwq.d.size());
// int tot=0;
// for(int i=l;i<=r;i++)if(a[i]==0)tot+=b[i];
// printf("%d %d\n",qwqwq.a[0],tot);
// printf("S[%d %d]:\n",l,r);
// for(int t:qwqwq.a)printf("%d ",t>=0?t:-1);puts("");
// for(int t:qwqwq.b)printf("%d ",t>=0?t:-1);puts("");
// for(int t:qwqwq.c)printf("%d ",t>=0?t:-1);puts("");
// for(int t:qwqwq.d)printf("%d ",t>=0?t:-1);puts("");
return qwqwq;
}
signed main()
{
int n=read();
// int n=2e5;
for(int i=1;i<=n;i++)a[i]=read();
std::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++)a[i]=read(),b[i]=read();
auto [a,b,c,d]=solve(1,n-1);
while(a.size()<=n)a.push_back(1e18);
while(b.size()<=n)b.push_back(1e18);
while(c.size()<=n)c.push_back(1e18);
while(d.size()<=n)d.push_back(1e18);
for(int i=1;i<=n/2;i++)
printf("%d ",min(a[i],min(b[i],min(c[i],d[i]))));
fprintf(stderr,"%.12lf\n",1.*clock()/CLOCKS_PER_SEC);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6068kb
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: 6068kb
input:
2 1 1000000000000000000
output:
-1486618625
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '-1486618625 '