結果

問題 No.2509 Beam Shateki
ユーザー tnakao0123tnakao0123
提出日時 2023-10-20 22:41:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,415 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 45,908 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 22:41:56
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 3 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 3 ms
4,348 KB
testcase_44 AC 3 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 3 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 3 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 1 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 1 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 WA -
testcase_60 AC 2 ms
4,348 KB
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- 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;
}
0