結果

問題 No.2509 Beam Shateki
ユーザー ripityripity
提出日時 2023-10-20 21:53:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 2,594 ms
コンパイル使用メモリ 222,556 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-20 21:55:29
合計ジャッジ時間 87,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,264 ms
4,372 KB
testcase_01 AC 1,349 ms
4,372 KB
testcase_02 AC 1,340 ms
4,372 KB
testcase_03 AC 1,281 ms
4,372 KB
testcase_04 AC 1,306 ms
4,372 KB
testcase_05 AC 1,291 ms
4,372 KB
testcase_06 AC 1,344 ms
4,372 KB
testcase_07 AC 1,273 ms
4,372 KB
testcase_08 AC 1,284 ms
4,372 KB
testcase_09 AC 1,290 ms
4,372 KB
testcase_10 AC 1,269 ms
4,372 KB
testcase_11 AC 1,276 ms
4,372 KB
testcase_12 AC 1,269 ms
4,372 KB
testcase_13 AC 1,240 ms
4,372 KB
testcase_14 AC 1,287 ms
4,372 KB
testcase_15 AC 1,335 ms
4,372 KB
testcase_16 AC 1,269 ms
4,372 KB
testcase_17 AC 1,296 ms
4,372 KB
testcase_18 AC 1,297 ms
4,372 KB
testcase_19 AC 1,263 ms
4,372 KB
testcase_20 AC 1,262 ms
4,372 KB
testcase_21 AC 1,246 ms
4,372 KB
testcase_22 AC 1,284 ms
4,372 KB
testcase_23 AC 1,295 ms
4,372 KB
testcase_24 AC 1,256 ms
4,372 KB
testcase_25 AC 1,268 ms
4,372 KB
testcase_26 AC 1,267 ms
4,372 KB
testcase_27 AC 1,258 ms
4,372 KB
testcase_28 AC 1,282 ms
4,372 KB
testcase_29 AC 1,247 ms
4,372 KB
testcase_30 AC 1,218 ms
4,372 KB
testcase_31 AC 1,251 ms
4,372 KB
testcase_32 AC 1,264 ms
4,372 KB
testcase_33 AC 1,263 ms
4,372 KB
testcase_34 AC 1,257 ms
4,372 KB
testcase_35 AC 1,247 ms
4,372 KB
testcase_36 AC 1,264 ms
4,372 KB
testcase_37 AC 1,309 ms
4,372 KB
testcase_38 AC 1,271 ms
4,372 KB
testcase_39 AC 1,289 ms
4,372 KB
testcase_40 AC 1,256 ms
4,372 KB
testcase_41 AC 1,290 ms
4,372 KB
testcase_42 AC 1,256 ms
4,372 KB
testcase_43 AC 1,263 ms
4,372 KB
testcase_44 AC 1,277 ms
4,372 KB
testcase_45 AC 1,236 ms
4,372 KB
testcase_46 AC 1,225 ms
4,372 KB
testcase_47 AC 1,236 ms
4,372 KB
testcase_48 AC 1,224 ms
4,372 KB
testcase_49 AC 1,245 ms
4,372 KB
testcase_50 AC 1,236 ms
4,372 KB
testcase_51 AC 1,278 ms
4,372 KB
testcase_52 AC 1,298 ms
4,372 KB
testcase_53 AC 1,278 ms
4,372 KB
testcase_54 AC 1,263 ms
4,372 KB
testcase_55 AC 1,305 ms
4,372 KB
testcase_56 AC 1,299 ms
4,372 KB
testcase_57 AC 1,260 ms
4,372 KB
testcase_58 AC 1,291 ms
4,372 KB
testcase_59 AC 1,287 ms
4,372 KB
testcase_60 AC 1,272 ms
4,372 KB
testcase_61 AC 1,261 ms
4,372 KB
testcase_62 WA -
testcase_63 AC 1,288 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<int> x = {1, 0, 1, 1};
	vector<int> y = {0, 1, 1, -1};
	vector<map<int, long long>> s(4);
	vector<vector<long long>> A(H, vector<long long>(W));
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			cin >> A[i][j];
			for( int k = 0; k < 4; k++ ) {
				s[k][x[k]*i+y[k]*j] += A[i][j];
			}
		}
	}
	long long ans = 0;
	for( int i = -500; i <= 500; i++ ) {
		for( int j = -500; j <= 500; j++ ) {
			for( int k = 0; k < 4; k++ ) {
				for( int l = 0; l < 4; l++ ) {
				  if( k == l ) continue;
					if( 0 <= i && i < H && 0 <= j && j < W ) ans = max(ans, s[k][x[k]*i+y[k]*j]+s[l][x[l]*i+y[l]*j]-A[i][j]);
					else  ans = max(ans, s[k][x[k]*i+y[k]*j]+s[l][x[l]*i+y[l]*j]);
				}
			}
		}
	}
	for( int i = 0; i < 4; i++ ) {
		vector<long long> v = {0};
		for( auto [j, k] : s[i] ) v.push_back(k);
		sort(v.rbegin(), v.rend());
		ans = max(ans, v[0]+v[1]);
	}
	cout << ans << endl;
}
0