某岛

… : "…アッカリ~ン . .. . " .. .
February 19, 2023

The 1st Universal Cup, Stage 4, Ukraine

https://qoj.ac/contest/1106

Problem A.

#include <lastweapon/io>
using namespace lastweapon;

const int N = int(2e5) + 9;
LL a[N]; int n;
LL z;

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    Rush {
        RD(n); REP(i, n) RD(a[i]); sort(a, a+n);
        LL z = a[n-1]*a[n-2] + a[1]*a[0];
        DWN(i, n-2, 0) z += a[i] * a[i+2];
        cout << z << endl;
    }
}

Problem B. Binary Arrays and Sliding Sums