QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111919 | #1875. Nein | lingchen | WA | 2ms | 3480kb | C++14 | 1.0kb | 2023-06-09 10:10:19 | 2023-06-09 10:10:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct node { int l,r,x; };
node a[500100];
long long s[1000100],sum;
long long f[1000100];
int stk[1000100],top;
long long ans=-1e18;
double slope(int a, int b) { return 1.0*(f[a]-f[b])/(s[a]-s[b]); }
int main()
{
int n;
cin>>n;
for(int i=1; i<=n; i++)
{
scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].x);
s[i]=a[i].l; s[i+n]=a[i].r;
}
s[n*2+1]=1;
sort(s+1, s+1+n*2+1);
sum=unique(s+1, s+1+n*2+1)-s-1;
for(int i=1; i<=n; i++)
{
int l=lower_bound(s+1, s+1+sum, a[i].l)-s;
int r=lower_bound(s+1, s+1+sum, a[i].r)-s;
f[l]+=a[i].x*2; f[r]+=a[i].x*2; f[0]-=a[i].x*2;
}
for(int i=1; i<=sum; i++) f[i]+=f[i-1];
for(int i=1; i<=sum; i++)
{
while(top>1&&slope(stk[top-1], stk[top])<slope(stk[top-1], i)) top--;
stk[++top]=i;
while(top>1&&slope(stk[top-1], stk[top])<4*s[i]) top--;
ans=max(ans, f[i]+f[stk[top]]-s[i]*s[stk[top]]*4);
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3480kb
input:
1 1
output:
0
result:
wrong answer expected '2', found '0'