結果
| 問題 |
No.2509 Beam Shateki
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-10-20 22:41:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,415 bytes |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 46,144 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-20 20:33:31 |
| 合計ジャッジ時間 | 2,089 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 WA * 3 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2509.cc: No.2509 Beam Shateki - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_H = 100;
const int MAX_W = 100;
/* typedef */
/* global variables */
int as[MAX_H][MAX_W];
int hs[MAX_H], vs[MAX_W], ps[MAX_H + MAX_W], qs[MAX_H + MAX_W];
/* subroutines */
/* main */
int main() {
int h, w;
scanf("%d%d", &h, &w);
int hw = h + w - 1;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++) {
scanf("%d", as[i] + j);
hs[i] += as[i][j];
vs[j] += as[i][j];
ps[i + j] += as[i][j];
qs[i + (w - 1 - j)] += as[i][j];
}
int maxs =
max(max(*max_element(hs, hs + h),
*max_element(vs, vs + w)),
max(*max_element(ps, ps + hw),
*max_element(qs, qs + hw)));
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++) {
int ds[4] = { hs[i], vs[j], ps[i + j], qs[i + (w - 1 - j)] };
sort(ds, ds + 4);
int s = ds[3] + ds[2] - as[i][j];
maxs = max(maxs ,s );
}
for (int i = 0; i < h; i++)
for (int j = i + 1; j < h; j++)
maxs = max(maxs, hs[i] + hs[j]);
for (int i = 0; i < w; i++)
for (int j = i + 1; j < w; j++)
maxs = max(maxs, vs[i] + vs[j]);
for (int i = 0; i < hw; i++)
for (int j = i + 1; j < hw; j++)
maxs = max(maxs, max(ps[i] + ps[j], qs[i] + qs[j]));
printf("%d\n", maxs);
return 0;
}
tnakao0123