Submission #2670489


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for (int i = 0; i < 8; i++) {
		vector<long long>vec;
		for (int j = 1; j <= N; j++) {
			long long S = 0;
			for (int k = 0; k < 3; k++) { if ((i / (1 << k)) % 2 == 0) S += a[j][k]; else S -= a[j][k]; }
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
		long long ans = 0;
		for (int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

Submission Info

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

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 400 / 400 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 3 ms 256 KB
in02.txt 3 ms 256 KB
in03.txt 3 ms 256 KB
in04.txt 3 ms 256 KB
in05.txt 3 ms 256 KB
in06.txt 3 ms 256 KB
in07.txt 3 ms 256 KB
in08.txt 2 ms 256 KB
in09.txt 2 ms 256 KB
in10.txt 2 ms 256 KB
in11.txt 3 ms 256 KB
in12.txt 3 ms 256 KB
in13.txt 2 ms 256 KB
in14.txt 3 ms 256 KB
in15.txt 3 ms 256 KB
in16.txt 3 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB