結果
問題 |
No.2094 Symmetry
|
ユーザー |
![]() |
提出日時 | 2023-05-05 18:06:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 149 ms / 2,000 ms |
コード長 | 1,110 bytes |
コンパイル時間 | 1,073 ms |
コンパイル使用メモリ | 116,024 KB |
最終ジャッジ日時 | 2025-02-12 17:17:39 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ ll N, K, cnt=0, ans=0, tot=0; cin >> N >> K; N *= 2; vector<ll> v1, v2; vector<string> S(N); vector<vector<ll>> C(N, vector<ll>(N)); for (int i=0; i<N; i++){ cin >> S[i]; for (auto c : S[i]) if (c == '#') cnt++; } for (int i=0; i<N; i++){ for (int j=0; j<N; j++){ cin >> C[i][j]; v1.push_back(C[i][j]); } for (int j=0; j<N/2; j++){ v2.push_back(C[i][j]+C[i][N-1-j]); } } sort(v1.begin(), v1.end(), greater<ll>()); sort(v2.begin(), v2.end(), greater<ll>()); for (int i=0; i<cnt; i++) tot += v1[i]; ans = tot; if (cnt % 2 == 0){ cnt /= 2; tot = 0; for (int i=0; i<cnt; i++) tot += v2[i]; ans = max(ans, tot+K); } cout << ans << endl; return 0; }