QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#42910 | #1880. Nikanor Loves Games | Sevennnnn | WA | 2ms | 16008kb | C++ | 1.2kb | 2022-08-05 08:59:56 | 2022-08-05 08:59:57 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f3f3f3f3f
#define meow(args...) fprintf(stderr,args)
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
int n,sum,ans=-inf;
int a[500010],b[500010],x[500010];
int f[1000010],c[1000010],O[1000010],tot;
int q[1000010],h,t;
signed main(){
#ifdef LOCAL
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
n=read();O[++tot]=1;
for(int i=1;i<=n;i++){
a[i]=read(),b[i]=read(),x[i]=read();
O[++tot]=a[i],O[++tot]=b[i];
}
sort(O+1,O+1+tot);tot=unique(O+1,O+1+tot)-O-1;
for(int i=1;i<=n;i++){
a[i]=lower_bound(O+1,O+1+tot,a[i])-O;
b[i]=lower_bound(O+1,O+1+tot,b[i])-O;
}
for(int i=1;i<=n;i++) c[a[i]]+=x[i],c[b[i]]+=x[i],sum+=x[i]+x[i];
for(int i=1;i<=tot;i++) c[i]+=c[i-1];
for(int i=1;i<=tot;i++) f[i]=c[i]+c[i]-sum;
h=1,t=0;
for(int i=tot;i>=1;i--){while(t&&f[i]>=f[q[t]]) t--;q[++t]=i;}
for(int i=1;i<=tot;i++){while(h<t&&f[q[h]]-O[i]*O[q[h]]*4<f[q[h+1]]-O[i]*O[q[h+1]]*4) h++;ans=max(ans,f[i]+f[q[h]]-O[i]*O[q[h]]*4);}
printf("%lld\n",ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 16008kb
input:
2 1 4 15 3 5 10
output:
10
result:
wrong answer 1st numbers differ - expected: '2.5000000', found: '10.0000000', error = '3.0000000'