結果
問題 | No.2509 Beam Shateki |
ユーザー |
![]() |
提出日時 | 2023-10-20 22:38:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,279 bytes |
コンパイル時間 | 517 ms |
コンパイル使用メモリ | 45,892 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-20 20:29:26 |
合計ジャッジ時間 | 2,215 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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);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 = 0;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]);int hw = h + w - 1;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;}