QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#42910#1880. Nikanor Loves GamesSevennnnnWA 2ms16008kbC++1.2kb2022-08-05 08:59:562022-08-05 08:59:57

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-05 08:59:57]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:16008kb
  • [2022-08-05 08:59:56]
  • 提交

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'