結果
| 問題 |
No.335 門松宝くじ
|
| コンテスト | |
| ユーザー |
airis
|
| 提出日時 | 2016-01-16 02:52:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,463 bytes |
| コンパイル時間 | 623 ms |
| コンパイル使用メモリ | 82,380 KB |
| 実行使用メモリ | 14,024 KB |
| 最終ジャッジ日時 | 2024-09-19 19:49:56 |
| 合計ジャッジ時間 | 9,617 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 1 TLE * 2 -- * 4 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#include <complex>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
#define EPS (1e-14)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;
int N, M;
int E[10][805];
ll mx, mx_index;
ll calc(int p) {
ll res = 0;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
for (int k = 0; k < N; k++) {
if (i == k) continue;
if (j == k) continue;
int a = i;
int b = j;
int c = k;
if (c < a) swap(a, c);
if (c < b) swap(b, c);
int tmp = 0;
if (E[p][a] < E[p][b] && E[p][b] > E[p][c]) {
tmp = E[p][b];
}
if (E[p][a] > E[p][b] && E[p][b] < E[p][c]) {
tmp = max(E[p][a], E[p][c]);
}
res += tmp;
}
}
}
return res;
}
void solve() {
for (int i = 0; i < M; i++) {
ll tmp = calc(i);
if (tmp > mx) {
mx = tmp;
mx_index = i;
}
}
cout << mx_index << endl;
}
int main() {
cin >> N >> M;
rep(i, M) rep(j, N) {
cin >> E[i][j];
}
solve();
return 0;
}
airis