QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#270173#1880. Nikanor Loves GameszhouhuanyiWA 1ms5624kbC++231.2kb2023-11-30 16:09:482023-11-30 16:09:49

Judging History

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

  • [2023-11-30 16:09:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5624kb
  • [2023-11-30 16:09:48]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 2000000
#define inf 1e36
using namespace std;
int read()
{
    char c=0;
    int sum=0;
    while (c<'0'||c>'9') c=getchar();
    while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
    return sum;
}
__int128 n,length,a[N+1],b[N+1],S[N+1],x[N+1],st[N+1],dque[N+1],top,ans,res;
int main()
{
    n=read(),ans=-inf;
    for (int i=1;i<=n;++i) a[i]=read(),b[i]=read(),x[i]=read(),res+=4*x[i],st[++length]=a[i],st[++length]=b[i];
    st[++length]=1;
    sort(st+1,st+length+1),length=unique(st+1,st+length+1)-st-1;
    for (int i=1;i<=n;++i) S[lower_bound(st+1,st+length+1,a[i])-st]+=2*x[i],S[lower_bound(st+1,st+length+1,b[i])-st]+=2*x[i];
    for (int i=1;i<=length;++i) S[i]+=S[i-1];
    for (int i=1;i<=length;++i)
    {
	while (top>1&&(S[i]-S[dque[top]])*(st[dque[top]]-st[dque[top-1]])>=(S[dque[top]]-S[dque[top-1]])*(st[i]-st[dque[top]])) top--;
	dque[++top]=i;
    }
    for (int i=1;i<=length;++i)
    {
	while (top>1&&S[dque[top]]-S[dque[top-1]]<=4*st[i]*(st[dque[top]]-st[dque[top-1]])) top--;
	ans=max(ans,S[dque[top]]+S[i]-4*st[dque[top]]*st[i]);
    }
    printf("%lld\n",(long long)(ans-res));
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5624kb

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'