QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#721407 | #1880. Nikanor Loves Games | Nt_Yester | WA | 1ms | 9776kb | C++20 | 1.4kb | 2024-11-07 16:03:02 | 2024-11-07 16:03:08 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 1000005
#define LL long long
#define INF 0x3f3f3f3f3f3f3f3f
inline int R() {
int x=0; bool f=0; char c=getchar();
while (!isdigit(c)) f|=(c=='-'),c=getchar();
while (isdigit(c)) x=x*10+c-'0',c=getchar();
return f?-x:x;
}
template<typename T>
void W(T x,int op=0) {
if (x<0) return putchar('-'),W(-x,op);
if (x>9) W(x/10); putchar(x%10+'0');
if (op) putchar(op==1?' ':'\n');
}
using namespace std;
int n,a[N],b[N],x[N],k,c[N]; LL ans=-INF,sum[N];
void sol(int l,int r,int L,int R) {
if (l>r) return;
int mid=(l+r>>1),pos=0; LL res=-INF;
for (int i=L;i<=R;i++)
if (sum[i]+sum[mid]-4ll*c[i]*c[mid]>res)
res=sum[i]+sum[mid]-4ll*c[i]*c[mid],pos=i;
ans=max(ans,res);
sol(l,mid-1,pos,R); sol(mid+1,r,L,pos);
}
int main() {
// freopen("b.in","r",stdin);
n=R();
for (int i=1;i<=n;i++)
c[++k]=a[i]=R(),c[++k]=b[i]=R(),x[i]=R();
c[++k]=1; LL Sum=0;
sort(c+1,c+k+1); k=unique(c+1,c+k+1)-c-1;
for (int i=1;i<=n;i++) {
a[i]=lower_bound(c+1,c+k+1,a[i])-c;
b[i]=lower_bound(c+1,c+k+1,b[i])-c;
sum[a[i]]+=x[i],sum[b[i]]+=x[i],Sum+=2*x[i];
}
for (int i=1;i<=k;i++) sum[i]+=sum[i-1];
for (int i=1;i<=k;i++) sum[i]=2*sum[i]-Sum;
sol(1,k,1,k); W(ans,2);
// printf("%.7lf\n",ans/4.0);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 9776kb
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'