結果
| 問題 | 
                            No.2094 Symmetry
                             | 
                    
| コンテスト | |
| ユーザー | 
                             _yurimoir
                         | 
                    
| 提出日時 | 2022-10-08 08:57:26 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 144 ms / 2,000 ms | 
| コード長 | 923 bytes | 
| コンパイル時間 | 3,138 ms | 
| コンパイル使用メモリ | 255,760 KB | 
| 実行使用メモリ | 8,192 KB | 
| 最終ジャッジ日時 | 2024-06-22 06:56:41 | 
| 合計ジャッジ時間 | 9,491 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 34 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    ll k;
    cin>>n>>k;
    int cnt=0;
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            char ch;
            cin>>ch;
            if(ch=='#')cnt++;
        }
    }
    ll c[2*n][2*n];
    vector<ll> clst(2*n*2*n,0);
    vector<ll> plst(2*n*n,0);
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            cin>>c[i][j];
            clst[2*n*i+j]=c[i][j];
        }
    }
    for(int i=0;i<2*n;i++){
        for(int j=0;j<n;j++){
            plst[n*i+j]=c[i][j]+c[i][2*n-1-j];
        }
    }
    sort(clst.rbegin(),clst.rend());
    sort(plst.rbegin(),plst.rend());
    ll ans=0;
    for(int i=0;i<cnt;i++){
        ans+=clst[i];
    }
    if(cnt%2==0){
        ll sym=k;
        for(int i=0;i<cnt/2;i++){
            sym+=plst[i];
        }
        ans=max(ans,sym);
    }
    cout<<ans<<endl;
}
            
            
            
        
            
_yurimoir