// No335.cpp : Defines the entry point for the console application. // #include #include #include #include #include #include #include #include #include using namespace std; typedef unsigned char uchar; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; int N; int M; vector E[3]; bool kado(int a, int b, int c) { if (a == b || b == c || a == c) return false; return (b < a && b < c) || (b > a && b > c); } int main() { cin >> N >> M; for (int i = 0; i < M; i++) { E[i].resize(N); for (int j = 0; j < N; j++) { scanf("%d", &E[i][j]); } } #define kArraySize (800 * 3 + 1) double kitaiMax = 0; int iKitaiMax = 0; for (int i = 0; i < M; i++) { int sums[kArraySize] = {0}; int kadoCount = 0; for (int i1 = 0; i1 < N-1; i1++) { for (int i2 = i1+1; i2 < N; i2++) { for (int i3 = 0; i3 < N; i3++) { if (i3 == i1 || i3 == i2)continue; int ii1 = min(i1, i3); int ii2 = ii1!=i3 ? min(i2, i3) : i2; int ii3 = max(i2, i3); if (kado(E[i][ii1], E[i][ii2], E[i][ii3])) { int sum = E[i][ii1] + E[i][ii2] + E[i][ii3]; sums[sum] ++; } kadoCount++; } } } double kitaiSum = 0; for (int j = 0; j < kArraySize; j++) { if (sums[j]) { kitaiSum += (double)j * (double)sums[j] / (double)kadoCount; } } //printf("%lf\n", kitaiSum); if (kitaiSum > kitaiMax) { kitaiMax = kitaiSum; iKitaiMax = i; } } cout << iKitaiMax << endl; return 0; }