Submission #3226919
Source Code Expand
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; using static System.Console; class Solver { Scanner sc = new Scanner(); public void Solve() { var N = sc.nextInt(); var M = sc.nextInt(); var arr = new long[N, 3]; for (int i = 0; i < N; i++) { arr[i, 0] = sc.nextLong(); arr[i, 1] = sc.nextLong(); arr[i, 2] = sc.nextLong(); } var D = 3; var ans = new long[8]; for (int i = 0; i < (1 << D); i++) { var hoge = new long[N]; for (int k = 0; k < N; k++) { long sum = 0; for (int j = 0; j < D; j++) { if ((1 & i >> j) == 1) { sum += arr[k, j]; } else { sum -= arr[k, j]; } } hoge[k] = sum; } ans[i] = hoge.OrderByDescending(l => l).Take(M).Sum(); } WriteLine(ans.Max()); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] args) { Solver s = new Solver(); s.Solve(); } }
Submission Info
Submission Time | |
---|---|
Task | D - Patisserie ABC |
User | r_k |
Language | C# (Mono 4.6.2.0) |
Score | 400 |
Code Size | 2586 Byte |
Status | AC |
Exec Time | 30 ms |
Memory | 13396 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 29 ms | 11636 KB |
in02.txt | AC | 30 ms | 11488 KB |
in03.txt | AC | 30 ms | 11488 KB |
in04.txt | AC | 30 ms | 11488 KB |
in05.txt | AC | 30 ms | 9440 KB |
in06.txt | AC | 30 ms | 11488 KB |
in07.txt | AC | 30 ms | 9440 KB |
in08.txt | AC | 28 ms | 11488 KB |
in09.txt | AC | 27 ms | 11488 KB |
in10.txt | AC | 27 ms | 11488 KB |
in11.txt | AC | 28 ms | 9440 KB |
in12.txt | AC | 28 ms | 11488 KB |
in13.txt | AC | 29 ms | 11316 KB |
in14.txt | AC | 28 ms | 11316 KB |
in15.txt | AC | 29 ms | 11316 KB |
in16.txt | AC | 30 ms | 13364 KB |
sample_01.txt | AC | 26 ms | 13396 KB |
sample_02.txt | AC | 26 ms | 9300 KB |
sample_03.txt | AC | 25 ms | 9300 KB |
sample_04.txt | AC | 25 ms | 11348 KB |