結果
| 問題 |
No.2094 Symmetry
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-10-08 00:23:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 1,254 bytes |
| コンパイル時間 | 509 ms |
| コンパイル使用メモリ | 52,424 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 22:44:09 |
| 合計ジャッジ時間 | 3,659 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2094.cc: No.2094 Symmetry - yukicoder
*/
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 250;
const int MAX_N2 = MAX_N * 2;
const int MAX_M = MAX_N2 * MAX_N2;
/* typedef */
typedef long long ll;
/* global variables */
char ss[MAX_N2][MAX_N2 + 4];
int cs[MAX_N2][MAX_N2], ucs[MAX_M];
/* subroutines */
/* main */
int main() {
int n;
ll k;
scanf("%d%lld", &n, &k);
int n2 = n * 2;
int bn = 0;
for (int i = 0; i < n2; i++) {
scanf("%s", ss[i]);
for (int j = 0; j < n2; j++)
if (ss[i][j] == '#') bn++;
}
int m = 0;
for (int i = 0; i < n2; i++)
for (int j = 0; j < n2; j++)
scanf("%d", cs[i] + j), ucs[m++] = cs[i][j];
sort(ucs, ucs + m, greater<int>());
ll sum = 0;
for (int i = 0; i < bn; i++) sum += ucs[i];
//printf("sum=%lld\n", sum);
if (! (bn & 1)) {
int m = 0;
for (int i = 0; i < n2; i++)
for (int j = 0; j < n; j++)
ucs[m++] = cs[i][j] + cs[i][n2 - 1 - j];
sort(ucs, ucs + m, greater<int>());
ll sum1 = k;
int maxi = min(bn / 2, m);
for (int i = 0; i < maxi; i++) sum1 += ucs[i];
sum = max(sum, sum1);
}
printf("%lld\n", sum);
return 0;
}
tnakao0123