QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#721257 | #1880. Nikanor Loves Games | ZepX_D | WA | 1ms | 5968kb | C++14 | 1.2kb | 2024-11-07 15:41:36 | 2024-11-07 15:41:37 |
Judging History
answer
#include <bits/stdc++.h>
#define fr first
#define se second
#define Un unsigned
#define LL long long
#define pb push_back
#define pii pair<int,int>
#define pLi pair<LL,int>
#define pLL pair<LL,LL>
#define __ __int128
#define ld long double
#define VE vector<LL>
#define db double
#define Ve vector<int>
using namespace std;
inline LL read()
{
LL x = 0,f = 1;char ch = getchar();
while(!isdigit(ch)) (ch == '-') && (f = -1),ch = getchar();
while(isdigit(ch)) x = x*10+ch-48,ch = getchar();
return x*f;
}
const int N = 1e6+5;
struct node{int x,k;}a[N];
LL s[N];
inline LL W(int x,int y){return s[x]+s[y]-4LL*a[x].x*a[y].x;}
int main()
{
int n = read();LL sum = 0;
for(int i = 1,x,y,k;i <= n;i++) x = read(),y = read(),k = read(),a[i] = {x,k},a[i+n] = {y,k},sum -= 4LL*k;
n <<= 1;
sort(a+1,a+n+1,[](node u,node v){return u.x < v.x;}),a[0].x = 1;
for(int i = 1;i <= n;i++) s[i] = s[i-1]+a[i].k*2;
int j = n;LL ans = -1e18;
for (int i = 0;i <= n;i++)
{
while(j > 0 && W(i,j-1) >= W(i,j)) j--;
ans = max(ans,W(i,j));
}
printf("%.6lf",(ans+sum)/4.0);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5924kb
input:
2 1 4 15 3 5 10
output:
2.500000
result:
ok found '2.5000000', expected '2.5000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5968kb
input:
1 2 2 8
output:
4.000000
result:
ok found '4.0000000', expected '4.0000000', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5872kb
input:
3 94 68 49 51 2 63 26 85 20
output:
-94.000000
result:
wrong answer 1st numbers differ - expected: '-73.0000000', found: '-94.0000000', error = '0.2876712'