結果
問題 | No.335 門松宝くじ |
ユーザー |
![]() |
提出日時 | 2019-12-11 14:02:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,376 bytes |
コンパイル時間 | 2,063 ms |
コンパイル使用メモリ | 176,288 KB |
実行使用メモリ | 13,884 KB |
最終ジャッジ日時 | 2024-06-24 07:39:52 |
合計ジャッジ時間 | 5,452 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | WA * 1 TLE * 1 -- * 8 |
ソースコード
#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; }