結果
| 問題 |
No.335 門松宝くじ
|
| コンテスト | |
| ユーザー |
hirokazu1020
|
| 提出日時 | 2016-01-16 00:19:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,616 bytes |
| コンパイル時間 | 959 ms |
| コンパイル使用メモリ | 96,420 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 19:40:55 |
| 合計ジャッジ時間 | 1,717 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 5 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:79:17: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
79 | cout << ans << endl;
| ^~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin >> n >> m;
int ans;
int a[800];
int mah[800], mat[800];
int mih[800], mit[800];
double maxv = - 1;
rep(i,m) {
rep(j, n)cin >> a[j];
mah[0] = mih[0] = a[0];
rep(j, n) {
mah[j] = max(mah[j],a[j]);
mih[j] = min(mih[j], a[j]);
}
mat[n-1] = mit[n-1] = a[n-1];
for (int j = n - 1; j >= 0; j--) {
mat[j] = max(mat[j], a[j]);
mit[j] = min(mit[j], a[j]);
}
double sum = 0;
rep(j, n) {
int ma, mi;
ma = mi = a[j];
for (int k = j + 1; k < n; k++) {
int x = 0;
if (max(a[j], a[k]) < ma) {
x = ma;
}
if (a[j] < a[k]) {
if (mah[j] > a[j])x = max(x, max(a[k], mah[j]));
else if (mat[k] < a[k])x = max(x, a[k]);
}
else if (a[j] > a[k]) {
if (mat[k] > a[k])x = max(x, max(a[j], mat[k]));
else if (mah[j] < a[j])x = max(x, a[j]);
}
sum += x;
ma = max(ma, a[k]);
mi = min(mi, a[k]);
}
}
double v = sum / (double)(n*(n - 1) / 2);
if (maxv < v) {
maxv = v;
ans = i;
}
}
cout << ans << endl;
return 0;
}
hirokazu1020