結果

問題 No.335 門松宝くじ
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-01-11 11:19:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,803 ms / 2,000 ms
コード長 1,668 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 92,300 KB
実行使用メモリ 7,596 KB
最終ジャッジ日時 2023-10-19 22:47:06
合計ジャッジ時間 12,670 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,588 KB
testcase_01 AC 5 ms
7,588 KB
testcase_02 AC 5 ms
7,588 KB
testcase_03 AC 5 ms
7,588 KB
testcase_04 AC 5 ms
7,588 KB
testcase_05 AC 279 ms
7,592 KB
testcase_06 AC 415 ms
7,592 KB
testcase_07 AC 1,198 ms
7,596 KB
testcase_08 AC 335 ms
7,596 KB
testcase_09 AC 1,798 ms
7,596 KB
testcase_10 AC 1,803 ms
7,596 KB
testcase_11 AC 1,794 ms
7,596 KB
testcase_12 AC 1,797 ms
7,596 KB
testcase_13 AC 1,770 ms
7,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

int isKadomatsu(int a, int b, int c){
  if((a<b&&a>c)||(a>b&&a<c)||(c<a&&c>b)||(c>a&&c<b))return 1;
  return 0;
}

int f(vector<int> v){
  int d[1005][1005];
  clr(d,0);
  rep(i,0,v.sz){
    rep(j,i+1,v.sz){
      rep(k,j+1,v.sz){
        if(isKadomatsu(v[i],v[j],v[k])==1){
          d[min(v[i],v[j])][max(v[i],v[j])] = max(d[min(v[i],v[j])][max(v[i],v[j])],max(v[i],max(v[j],v[k])));
          d[min(v[i],v[k])][max(v[i],v[k])] = max(d[min(v[i],v[k])][max(v[i],v[k])],max(v[i],max(v[j],v[k])));
          d[min(v[j],v[k])][max(v[j],v[k])] = max(d[min(v[j],v[k])][max(v[j],v[k])],max(v[i],max(v[j],v[k])));
        }
      }
    }
  }
  int ret = 0;
  rep(i,1,v.sz+1){
    rep(j,i+1,v.sz+1){
      ret += d[i][j];
    }
  }
  return ret;
}

int main(){
  int n,m;
  cin>>n>>m;
  long long mx = 0;
  int index = 0;
  rep(i,0,m){
    vector<int> v;
    rep(j,0,n){
      int a;
      cin>>a;
      v.pb(a);
    }
    long long b = f(v);
    if(b>mx){
      mx = b;
      index = i;
    }
  }
  cout << index << endl;
  return 0;
}

// 想定誤解法
0