結果

問題 No.335 門松宝くじ
ユーザー yumakmcyumakmc
提出日時 2016-02-12 07:26:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 987 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 150,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 02:40:45
合計ジャッジ時間 5,536 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 74 ms
4,376 KB
testcase_06 AC 113 ms
4,380 KB
testcase_07 AC 249 ms
4,376 KB
testcase_08 AC 987 ms
4,380 KB
testcase_09 AC 480 ms
4,376 KB
testcase_10 AC 398 ms
4,376 KB
testcase_11 AC 380 ms
4,376 KB
testcase_12 AC 397 ms
4,380 KB
testcase_13 AC 383 ms
4,380 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 =es[l];
						}
					}
					for (int l = j+1; l < k; ++l) {
						if (es[l] >nmoney) {
							if (check(es[j], es[l], es[k]))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 =es[l];
						}
					}
					nkitai += nmoney;
				
			}
		}
		kitais[i] = make_pair(nkitai, 10-i);
	}
	cout << 10-(*max_element(kitais.begin(), kitais.end())).second << endl;
	return 0;
}
0