QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#42911#1880. Nikanor Loves GamesSevennnnnWA 5ms16124kbC++1.2kb2022-08-05 09:00:312022-08-05 09:00:32

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 09:00:32]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:16124kb
  • [2022-08-05 09:00:31]
  • 提交

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("%.10lf\n",ans/4.0);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 16124kb

input:

2
1 4 15
3 5 10

output:

2.5000000000

result:

ok found '2.5000000', expected '2.5000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 2ms
memory: 15872kb

input:

1
2 2 8

output:

4.0000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 16044kb

input:

3
94 68 49
51 2 63
26 85 20

output:

-94.0000000000

result:

wrong answer 1st numbers differ - expected: '-73.0000000', found: '-94.0000000', error = '0.2876712'