Submission #2857554


Source Code Expand

#include <iostream>
#include <climits>
#include <algorithm>

#define LL long long
#define INF LONG_LONG_MAX
#define MAXN 1100

LL v[8][MAXN + 1];


LL abs(LL n) {
    if (n < 0)
        return -n;
    return n;
}


int main()
{
    int n, m;
    LL a, b, c;
    std::cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        std::cin >> a >> b >> c;
        for (int j = 0; j <= 1; j++)
            for (int k = 0; k <= 1; k++)
                for (int l = 0; l <= 1; l++) {
                    v[4 * l + 2 * k + j][i] = (2 * j - 1) * a + (2 * k - 1) * b + (2 * l - 1) * c;
                }
    }
    for (int i = 0; i < 8; i++)
        std::sort(v[i] + 1, v[i] + n + 1);
    LL max = -INF/2;
    for (int i = 0; i < 8; i++) {
        LL s = 0;
        for (int j = n; j >= n - m + 1; j--)
            s += v[i][j];
        if (s > max)
            max = s;
    }
    std::cout << max;
}

Submission Info

Submission Time
Task D - Patisserie ABC
User FizZ
Language C++14 (GCC 5.4.1)
Score 400
Code Size 932 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
in01.txt AC 3 ms 256 KB
in02.txt AC 3 ms 256 KB
in03.txt AC 3 ms 256 KB
in04.txt AC 3 ms 256 KB
in05.txt AC 3 ms 256 KB
in06.txt AC 3 ms 256 KB
in07.txt AC 3 ms 256 KB
in08.txt AC 2 ms 256 KB
in09.txt AC 2 ms 256 KB
in10.txt AC 2 ms 256 KB
in11.txt AC 3 ms 256 KB
in12.txt AC 3 ms 256 KB
in13.txt AC 2 ms 256 KB
in14.txt AC 2 ms 256 KB
in15.txt AC 2 ms 256 KB
in16.txt AC 2 ms 256 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB