The 1st Universal Cup, Stage 4, Ukraine

https://qoj.ac/contest/1106 Pr…


·

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

Discussion

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。