QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721249#1880. Nikanor Loves GamesZepX_DWA 1ms5676kbC++141.1kb2024-11-07 15:40:312024-11-07 15:40:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 15:40:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5676kb
  • [2024-11-07 15:40:31]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'