結果

問題 No.335 門松宝くじ
ユーザー roarisroaris
提出日時 2019-12-11 14:02:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,376 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 172,028 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-06 13:03:41
合計ジャッジ時間 5,271 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
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 pair<int, int> P;

int main() {
    int N, M; cin >> N >> M;
    int v_max = -1;
    int ans = -1;
    
    for (int i=0; i<M; i++) {
        int E[N];
        int idx[N];
        
        for (int i=0; i<N; i++) {
            cin >> E[i];
            E[i]--;
            idx[E[i]] = i;
        }
        
        int v = 0;
        
        for (int j=0; j<N; j++) {
            for (int k=j+1; k<N; k++) {
                int prof = 0;
                
                for (int l=0; l<N; l++) {
                    if (l==j || l==k) continue;
                    
                    vector<P> vec;
                    vec.push_back(P(j, idx[j]));
                    vec.push_back(P(k, idx[k]));
                    vec.push_back(P(l, idx[l]));
                    sort(vec.begin(), vec.end(), [](auto const& lhs, auto const& rhs) {return lhs.second<rhs.second;});
                    
                    if ((vec[0].first<vec[1].first && vec[1].first>vec[2].first) || (vec[0].first<vec[1].first && vec[1].first>vec[2].first)) {
                        prof = max(prof, max({j, k, l}));
                    }
                }
                
                v += prof;
            }
        }
        
        if (v>v_max) {
            v_max = v;
            ans = i;
        }
    }
    
    cout << ans << endl;
}
0