結果

問題 No.335 門松宝くじ
ユーザー yumakmcyumakmc
提出日時 2016-02-12 07:27:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 853 ms / 2,000 ms
コード長 1,240 bytes
コンパイル時間 1,456 ms
コンパイル使用メモリ 165,584 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 02:32:39
合計ジャッジ時間 5,952 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 84 ms
4,348 KB
testcase_06 AC 125 ms
4,348 KB
testcase_07 AC 306 ms
4,348 KB
testcase_08 AC 853 ms
4,348 KB
testcase_09 AC 542 ms
4,348 KB
testcase_10 AC 476 ms
4,348 KB
testcase_11 AC 462 ms
4,348 KB
testcase_12 AC 489 ms
4,348 KB
testcase_13 AC 467 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

bool check(int l, int m, int r) {
	return (m > l&&m > r) || (m < l&&m < r);
}
int main() {
	int N, M; cin >> N >> M;
	vector<pair<long long int,int>>kitais(M);
	for (int i = 0; i < M; ++i) {
		long long nkitai = 0;
		vector<int>es;
		for (int j = 0; j < N; ++j) {
			int e; cin >> e; es.push_back(e);
		}
		for (int j = 0; j < N; ++j) {
			for (int k = j+1; k < N; ++k) {
					int nmoney = 0;
					for (int l = 0; l < j; ++l) {
						if (es[l] >nmoney) {
							if (check(es[l], es[j], es[k]))nmoney =max(nmoney,es[l]);
						}
					}
					for (int l = j+1; l < k; ++l) {
						if (es[l] >nmoney) {
							if (check(es[j], es[l], es[k]))nmoney = max(nmoney, es[l]);
						}
					}
					if (nmoney == N) {
						nkitai += nmoney;
						continue;
					}
					for (int l = k + 1; l < N; ++l) {
						if (es[l] >nmoney) {
							if (check(es[j], es[k], es[l]))nmoney = max(nmoney, es[l]);
						}
					}
					nkitai += nmoney;
				
			}
		}
		kitais[i] = make_pair(nkitai, 10-i);
	}
	cout << 10-(*max_element(kitais.begin(), kitais.end())).second << endl;
	return 0;
}
0