結果

問題 No.335 門松宝くじ
ユーザー latte0119latte0119
提出日時 2016-01-16 15:23:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,631 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 160,816 KB
実行使用メモリ 9,516 KB
最終ジャッジ日時 2023-10-20 00:06:26
合計ジャッジ時間 1,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,720 KB
testcase_01 AC 1 ms
5,716 KB
testcase_02 AC 2 ms
5,724 KB
testcase_03 AC 2 ms
5,728 KB
testcase_04 AC 1 ms
5,724 KB
testcase_05 AC 5 ms
8,476 KB
testcase_06 AC 7 ms
8,476 KB
testcase_07 AC 9 ms
9,516 KB
testcase_08 AC 7 ms
9,516 KB
testcase_09 AC 13 ms
9,516 KB
testcase_10 AC 13 ms
9,516 KB
testcase_11 AC 13 ms
9,516 KB
testcase_12 AC 13 ms
9,516 KB
testcase_13 AC 13 ms
9,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int SIZE=888;

int N,M;
int E[SIZE];

int ma[SIZE][SIZE],mi[SIZE][SIZE];

int get(){
    rep(i,N)cin>>E[i];
    rep(i,N){
      ma[i][i]=mi[i][i]=E[i];
      reps(j,i+1,N){
        ma[i][j]=max(ma[i][j-1],E[j]);
        mi[i][j]=min(mi[i][j-1],E[j]);
      }
    }

    int ret=0;
    rep(i,N){
      reps(j,i+1,N){
        int z=0;

        int t=ma[i+1][j-1];
        if(t>max(E[i],E[j]))chmax(z,t);
        t=mi[i+1][j-1];
        if(t<min(E[i],E[j])&&t)chmax(z,max(E[i],E[j]));

        if(E[i]>E[j]){
          t=(i?mi[0][i-1]:0);
          if(t<E[i]&&t)chmax(z,E[i]);
          t=(j!=N-1)?ma[j+1][N-1]:0;
          if(t>E[j]&&t)chmax(z,max(E[i],t));
        }
        else{
          t=i?ma[0][i-1]:0;
          if(t>E[i]&&t)chmax(z,max(E[j],t));
          t=(j!=N-1)?mi[j+1][N-1]:0;
          if(t<E[j]&&t)chmax(z,E[j]);
        }
        ret+=z;
      }
    }
    return ret;
}

int main(){
    cin>>N>>M;

    int idx=0,val=0;
    rep(i,M){
      int tmp=get();
      if(tmp>val){
          val=tmp;
          idx=i;
      }
    }
    cout<<idx<<endl;
    return 0;
}
0