結果

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

テストケース

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

ソースコード

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) {
				if (j == k)continue;
				else {
					int nmoney = 0;
					for (int l = 0; l < j; ++l) {
						if (check(es[l], es[j], es[k]))nmoney = max(nmoney, es[l]);
					}
					if (nmoney == N) {
						nkitai += nmoney;
						break;
					}
					for (int l = j+1; l < k; ++l) {
						if (check(es[j], es[l], es[k]))nmoney = max(nmoney, es[l]);
					}
					if (nmoney == N) {
						nkitai += nmoney;
						break;
					}
					for (int l = k + 1; l < N; ++l) {
						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