結果

問題 No.335 門松宝くじ
ユーザー face4face4
提出日時 2019-02-11 12:44:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,097 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 67,528 KB
実行使用メモリ 9,636 KB
最終ジャッジ日時 2023-09-25 09:33:06
合計ジャッジ時間 10,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    int ans = -1;
    long double e = -1;
    for(int i = 0; i < m; i++){
        int x[n];
        for(int j = 0; j < n; j++)  cin >> x[j];
        auto calc = [&](int a, int b, int c) -> int{
            if(b > c)   swap(b, c);
            if(a > b)   swap(a, b);
            if(b > c)   swap(b, c);
            if((x[b]-x[a])*(x[b]-x[c]) > 0) return max({x[a], x[b], x[c]});
            else                            return 0;
        };
        ll sum = 0;
        for(int j = 0; j < n; j++){
            for(int k = j+1; k < n; k++){
                int tmps = 0;
                for(int l = 0; l < n; l++){
                    if(j == l || k == l)    continue;
                    tmps = max(tmps, calc(j, k, l));
                }
                sum += tmps;
            }
        }
        long double score = (double)sum / m / (m-1);
        if(score > e){
            e = score;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}
0