QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#270173 | #1880. Nikanor Loves Games | zhouhuanyi | WA | 1ms | 5624kb | C++23 | 1.2kb | 2023-11-30 16:09:48 | 2023-11-30 16:09:49 |
Judging History
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'