結果

問題 No.335 門松宝くじ
ユーザー btkbtk
提出日時 2016-01-16 00:29:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 978 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 161,648 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:50:18
合計ジャッジ時間 15,602 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> V;


int solve(V& v){
    int n=v.size();
    int res=0;
    for(int _i = 0; _i < n; _i++){
        for(int _j = _i+1; _j < n; _j++){
            int top=0;
            for(int _k = 0; _k < n; _k++)
                if(_i!=_k&&_j!=_k){
                    int i=min(_i,_k),k=max(_j,_k);
                    int j=_k;
                    if(i==_k)j=_i;
                    if(j==_k)j=_j;
                    if(v[i]>v[j]&&v[k]>v[j])top=max(top,max(v[i],v[k]));
                    if(v[i]<v[j]&&v[k]<v[j])top=max(top,v[j]);
                
            }
            res+=top;
        }
    }
    //cout<<res<<endl;
    return res;
}
int main() {
    int N,M;
    cin>>N>>M;
    int id=0;
    int top=0;
    V v(N);
    for(int i = 0; i < M; i++){
        for(auto& it : v)cin>>it;
        int t=solve(v);
        if(t>top){
            top=t;
            id=i;
        }
    }
    cout<<id<<endl;
    return 0;
}
0