被错解水过去了
查看原帖
被错解水过去了
640050
QSH_AK_IOI楼主2023/1/1 13:10

请求加强数据

错解

取所有数平均数 xx,然后每个 ai,bia_i, b_i 中选更远离 xx 的那个。

#include <bits/stdc++.h>
using namespace std;
#define file(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout)
#define writesp(x) write(x), putchar(' ')
#define writeln(x) write(x), putchar('\n')
#define int __int128
inline int read()
{
    int x = 0;
    bool f = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = 1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 3) + (x << 1) + (ch ^ 48);
        ch = getchar();
    }
    return (f ? -x : x);
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + 48);
}
const int N = 1e6 + 10, inf = 0x7fffffff;
int n, a[N], b[N], c[N];
#define abs(x) (((x) < 0) ? (-(x)) : (x))
signed main()
{
    n = read();
    int i;
    for (i = 1; i <= n; i++)
        a[i] = read() * n;
    for (i = 1; i <= n; i++)
        b[i] = read() * n;
    int ave = 0, ans = 0;
    for (i = 1; i <= n; i++)
        ave += a[i] + b[i];
    ave /= n;
    for (i = 1; i <= n; i++)
    {
        if (abs(a[i] + a[i] - ave) > abs(b[i] + b[i] - ave))
            c[i] = a[i];
        else
            c[i] = b[i];
    }
    ave = 0;
    for (i = 1; i <= n; i++)
    {
        ave += c[i];
    }
    ave /= n;
    for (i = 1; i <= n; i++)
    {
        ans += (ave - c[i]) * (ave - c[i]);
    }
    write(ans / n);
    return 0;
}

hack 数据:

// .in
10
45852717 57442408 229475647 300870816 518793259 575195358 613957267 620267314 754957905 912913157 
83702481 158477316 280134009 335791298 538924681 721299418 791257273 810999252 928072460 984298843 
// .out
11480874365596262625
// .ans
11485296760042870401
2023/1/1 13:10
加载中...