QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#721249 | #1880. Nikanor Loves Games | ZepX_D | WA | 1ms | 5676kb | C++14 | 1.1kb | 2024-11-07 15:40:31 | 2024-11-07 15:40:31 |
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));
}
cout << ans+sum;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5676kb
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'