結果
問題 | No.2094 Symmetry |
ユーザー |
|
提出日時 | 2022-10-07 21:49:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 161 ms / 2,000 ms |
コード長 | 877 bytes |
コンパイル時間 | 5,484 ms |
コンパイル使用メモリ | 196,396 KB |
最終ジャッジ日時 | 2025-02-07 23:16:05 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main () {int N;ll K;cin >> N >> K;N *= 2;int b = 0;for (int i = 0; i < N * N; i ++) {char c;cin >> c;b += (c == '#');}ll C1[300000];for (int i = 0; i < N * N; i ++) {cin >> C1[i];}ll C2[300000];for (int i = 0; i < (N * N) / 2; i ++) {int p = i / (N / 2), q = i % (N / 2);C2[i] = C1[p * N + q] + C1[p * N + N - q - 1];}sort(C1, C1 + (N * N));sort(C2, C2 + (N * N / 2));ll ans1 = 0;for (int i = 0; i < b; i ++) {ans1 += C1[N * N - 1 - i];}if (b % 2) {cout << ans1 << endl;return 0;}ll ans2 = 0;for (int i = 0; i < b / 2; i ++) {ans2 += C2[N * N / 2 - 1 - i];}cout << max(ans1, ans2 + K) << endl;}