結果

問題 No.2094 Symmetry
ユーザー 沙耶花沙耶花
提出日時 2022-10-07 21:32:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,124 bytes
コンパイル時間 6,266 ms
コンパイル使用メモリ 266,932 KB
実行使用メモリ 8,072 KB
最終ジャッジ日時 2023-09-03 00:30:19
合計ジャッジ時間 10,285 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 132 ms
7,928 KB
testcase_10 AC 134 ms
7,928 KB
testcase_11 AC 134 ms
7,892 KB
testcase_12 AC 134 ms
7,944 KB
testcase_13 AC 136 ms
7,876 KB
testcase_14 AC 133 ms
7,892 KB
testcase_15 AC 136 ms
7,972 KB
testcase_16 AC 138 ms
8,072 KB
testcase_17 AC 136 ms
7,996 KB
testcase_18 AC 139 ms
8,000 KB
testcase_19 AC 138 ms
7,924 KB
testcase_20 AC 137 ms
7,836 KB
testcase_21 AC 137 ms
7,936 KB
testcase_22 AC 136 ms
7,972 KB
testcase_23 AC 137 ms
7,936 KB
testcase_24 AC 137 ms
7,912 KB
testcase_25 AC 137 ms
8,072 KB
testcase_26 AC 141 ms
7,912 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 114 ms
7,996 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 126 ms
7,936 KB
testcase_31 AC 114 ms
7,892 KB
testcase_32 AC 123 ms
7,840 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 87 ms
7,920 KB
testcase_35 AC 72 ms
7,968 KB
testcase_36 AC 70 ms
8,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	long long n,k;
	cin>>n>>k;
	n *= 2;
	vector<string> s(n);
	rep(i,n)cin>>s[i];
	long long w = 0;
	rep(i,n){
		rep(j,n){
			if(s[i][j]=='.')w++;
		}
	}
	
	vector c(n,vector<long long>(n));
	rep(i,n){
		rep(j,n)cin>>c[i][j];
	}
	long long ans = -Inf64;
	
	{
		long long t = 0;
		vector<long long> diff;
		rep(i,n){
			rep(j,n/2){
				t += c[i][j];
				diff.push_back(-c[i][j]);
				t += c[i][n-1-j];
				diff.push_back(-c[i][n-1-j]);
			}
		}
		sort(diff.rbegin(),diff.rend());
		rep(i,w)t += diff[i];
		ans = max(ans,t);
	//	cout<<ans<<endl;
	}
	{
		long long t = 0;
		vector<long long> diff;
		rep(i,n){
			rep(j,n/2){
				t += c[i][j] + c[i][n-1-j];
				diff.push_back(-(c[i][j]+c[i][n-1-j]));
			}
		}
		sort(diff.rbegin(),diff.rend());
		if(w%2==0){
			rep(j,w/2){
				t += diff[j];
			}
			ans = max(ans,t+k);
		}
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0