結果

問題 No.2094 Symmetry
ユーザー otoshigootoshigo
提出日時 2022-10-07 21:34:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 206,948 KB
実行使用メモリ 9,180 KB
最終ジャッジ日時 2023-09-03 00:37:22
合計ジャッジ時間 5,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 72 ms
9,120 KB
testcase_10 AC 72 ms
9,124 KB
testcase_11 AC 72 ms
9,124 KB
testcase_12 AC 72 ms
9,024 KB
testcase_13 AC 59 ms
7,280 KB
testcase_14 AC 72 ms
9,128 KB
testcase_15 AC 72 ms
9,052 KB
testcase_16 AC 71 ms
9,180 KB
testcase_17 AC 60 ms
7,176 KB
testcase_18 AC 60 ms
7,268 KB
testcase_19 AC 72 ms
9,092 KB
testcase_20 AC 72 ms
9,132 KB
testcase_21 AC 72 ms
9,104 KB
testcase_22 AC 71 ms
9,040 KB
testcase_23 AC 59 ms
7,260 KB
testcase_24 AC 60 ms
7,260 KB
testcase_25 AC 72 ms
9,040 KB
testcase_26 AC 72 ms
9,040 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 45 ms
9,112 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 47 ms
9,108 KB
testcase_31 AC 45 ms
9,120 KB
testcase_32 AC 48 ms
9,124 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 37 ms
9,032 KB
testcase_35 AC 33 ms
9,032 KB
testcase_36 AC 33 ms
7,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = (n) - 1; i >= 0; i--)

int n;
ll k,C[510][510];
int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin>>n>>k;
    int cnt=0;
    rep(i,2*n){
        string s;
        cin>>s;
        rep(j,2*n)if(s[j]=='#')cnt++;
    }
    vector<ll>v;
    rep(i,2*n)rep(j,2*n){
        cin>>C[i][j];
        v.push_back(C[i][j]);
    }
    sort(v.rbegin(),v.rend());
    ll ans=0;
    rep(i,cnt)ans+=v[i];
    if(cnt%2==0){
        vector<ll>w;
        rep(i,2*n){
            rep(j,n){
                w.push_back(C[i][j]+C[i][2*n-1-j]);
            }
        }
        sort(w.rbegin(),w.rend());
        rep(i,cnt/2)k+=w[i];
        ans=max(ans,k);
    }
    cout<<ans<<"\n";
}
0