結果

問題 No.335 門松宝くじ
ユーザー airisairis
提出日時 2016-01-16 02:52:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,463 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 81,776 KB
実行使用メモリ 7,712 KB
最終ジャッジ日時 2023-10-19 23:55:06
合計ジャッジ時間 10,084 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,688 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 605 ms
4,348 KB
testcase_06 WA -
testcase_07 TLE -
testcase_08 AC 1,701 ms
4,348 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#include <complex>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
#define EPS (1e-14)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int N, M;
int E[10][805];

ll mx, mx_index;

ll calc(int p) {

	ll res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k < N; k++) {
				if (i == k) continue;
				if (j == k) continue;

				int a = i;
				int b = j;
				int c = k;

				if (c < a) swap(a, c);
				if (c < b) swap(b, c);

				int tmp = 0;
				if (E[p][a] < E[p][b] && E[p][b] > E[p][c]) {
					tmp = E[p][b];
				}
				if (E[p][a] > E[p][b] && E[p][b] < E[p][c]) {
					tmp = max(E[p][a], E[p][c]);
				}
				res += tmp;
			}
		}
	}
	return res;
}

void solve() {
	for (int i = 0; i < M; i++) {
		ll tmp = calc(i);
		if (tmp > mx) {
			mx = tmp;
			mx_index = i;
		}
	}
	cout << mx_index << endl;
}


int main() {
	cin >> N >> M;
	rep(i, M) rep(j, N) {
		cin >> E[i][j];
	}
	solve();
	return 0;
}


0