結果

問題 No.335 門松宝くじ
ユーザー btkbtk
提出日時 2016-01-16 00:25:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 949 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 164,968 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 23:49:27
合計ジャッジ時間 5,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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++){
                vector<int> t{_i,_j,_k};
                sort(t.begin(),t.end());
                int i=t[0],j=t[1],k=t[2];
                if(i!=k&&j!=k){
                    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