import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.array; void main(){ auto buf = readln.chomp.split(" ").map!(to!int); int N = buf[0]; int M = buf[1]; int[][] pointTable = new int[][](N+1, N+1); int getPoint(int[] arr, int acc = 0){ if(!arr.length) return acc; int tempPoint; foreach(e; arr[1..$]){ tempPoint += pointTable[arr[0]][e]; } return getPoint(arr[1..$], acc + tempPoint); } foreach(i; 0..M){ auto buf2 = readln.chomp.split(" ").map!(to!int); pointTable[buf2[0]][buf2[1]] = buf2[2]; } int res = 0; int[] items = iota(0, N).array; do{ if(getPoint(items) > res) res = getPoint(items); } while(nextPermutation(items)); res.writeln; }