結果

問題 No.335 門松宝くじ
ユーザー odan3240odan3240
提出日時 2016-01-15 23:44:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,172 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 103,216 KB
実行使用メモリ 7,724 KB
最終ジャッジ日時 2023-10-19 23:41:15
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

bool isKado(int a,int b,int c) {
    if(a==b) return false;
    if(b==c) return false;
    if(c==a) return false;
    vector<int> vec;
    vec.pb(a);
    vec.pb(b);
    vec.pb(c);
    sort(all(vec));
    return vec[1]==a||vec[1]==c;
}
string to_s(P p) {
    stringstream ss;
    ss << "(";
    ss << p.fr;
    ss << ", ";
    ss << p.sc;
    ss << ")";
    return ss.str();
}
bool isKado(vector<int> vec,int i,int j,int k) {
    vector<P> v;
    v.push_back(P(i,vec[i]));
    v.push_back(P(j,vec[j]));
    v.push_back(P(k,vec[k]));
    sort(all(v));
    //cout<<__LINE__<<": "<<to_s(v[0])<<", "<<to_s(v[1])<<", "<<to_s(v[2])<<endl;
    return isKado(v[0].sc,v[1].sc,v[2].sc);
}

double func(vector<int> E) {
    int sum=0;
    int cnt=0;
    rep(i,E.size()) rep(j,E.size()) if(i<j) {
        int t=0;
        rep(k,E.size()) if(i!=k&&j!=k) {
            //cout<<__LINE__<<": "<<E[i]<<", "<<E[j]<<", "<<E[k]<<endl;
            if(!isKado(E,i,j,k)) continue;

            t=max(t,max({E[i],E[j],E[k]}));
        }
        //cout<<E[i]<<", "<<E[j]<<": "<<t<<endl;
        cnt++;
        sum+=t;
    }
    //cout<<sum<<", "<<cnt<<endl;

    return 1.0*sum/cnt;
}
int N,M;
vector<int> E[802];
int main() {
    cin>>N>>M;
    double maxi=0;
    int ans=0;
    rep(i,M) rep(j,N) {
        int t;
        cin>>t;
        E[i].push_back(t);
    }
    rep(i,M) {
        double t=func(E[i]);
        //cout<<i<<": "<<t<<endl;
        if(maxi<t) {
            maxi=t;
            ans=i;
        }
    }
    cout<<ans<<endl;

    return 0;
}
0