結果

問題 No.335 門松宝くじ
ユーザー lip_of_cygnuslip_of_cygnus
提出日時 2016-02-06 00:57:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,386 ms / 2,000 ms
コード長 1,692 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 69,444 KB
実行使用メモリ 6,132 KB
最終ジャッジ日時 2023-10-21 19:22:34
合計ジャッジ時間 10,137 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
4,348 KB
testcase_05 AC 211 ms
5,200 KB
testcase_06 AC 312 ms
5,200 KB
testcase_07 AC 923 ms
6,132 KB
testcase_08 AC 208 ms
6,132 KB
testcase_09 AC 1,380 ms
6,132 KB
testcase_10 AC 1,372 ms
6,132 KB
testcase_11 AC 1,386 ms
6,132 KB
testcase_12 AC 1,382 ms
6,132 KB
testcase_13 AC 1,358 ms
6,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <sstream>
#include <queue>
 
using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
#define debug(X) cout<<"["<<#X<<"]"<<X<<endl;
#define debug2(X) cout<<X<<endl;

#define MAX_N 800
#define MAX_M 3

const int INF=1e8;
typedef pair<int,int>P;

//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
//	queue<P> que;

#include <deque>
int i,j,N,M;
int E[MAX_N];
int ER[MAX_N];
int kumi[MAX_N][MAX_N];
int kitai=0;
bool f=false;
bool solve(){
		f =false;
		int sum=0;
		rep (k,N)rep(l,N)kumi[k][l]=0;
		int k=0;
		rep(k,N-1){
			rep2(l,0,k){
				rep2(m,k+1,N){
			//	debug(k);
			//	debug(l);
			//	debug(m);
				
				if ((E[l]<E[k]&& E[k]<E[m])||(E[m]<E[k] &&E[k]<E[l])){}

				else {

					
				int maxN=max(E[l],max(E[k],E[m]));
				int minN=min(E[l],min(E[k],E[m]));
				int midN=-maxN-minN+E[l]+E[m]+E[k];
				if (maxN>kumi[maxN][minN]){kumi[maxN][minN]=maxN;}
				if (maxN>kumi[maxN][midN]){kumi[maxN][midN]=maxN;}
				if (maxN>kumi[midN][minN]){kumi[midN][minN]=maxN;}
			
				}
				//	debug (sum);
				}
				
			} //kの位置
			//debug(sum);	
		}

		rep (k,N)rep(l,N)sum+=kumi[k][l];
		
		//debug(sum);
		if (kitai<sum){kitai =sum;return true;}
		else return false;
}

int main(){
	int res2=0;
	cin>>N>>M;
	rep(j,M){rep(i,N){
	cin>>E[i];
	ER[E[i]-1]=i;
	}
	if (solve()) res2=j;
	}
	
	
	cout <<res2<<endl;
	
}
0