結果

問題 No.2094 Symmetry
ユーザー kyushu1996kyushu1996
提出日時 2022-10-08 19:01:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,289 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 89,272 KB
実行使用メモリ 9,884 KB
最終ジャッジ日時 2023-09-05 00:34:16
合計ジャッジ時間 4,789 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 38 ms
9,592 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#define ll long long
using namespace std;

// link : https://yukicoder.me/problems/no/2094
// category : grpha, symmetry

int main() {
	
    int n,k,cnt=0;
    cin>>n>>k;

    for(int i=0;i<2*n;i++){
        string s; cin>>s;
        for(int j=0;j<2*n;j++){
            if(s[j]=='#') cnt++;
        }
    }

    int C[n*2][n*2]={};
    vector<int> Cline;

    for(int i=0;i<n*2;i++){
        for(int j=0;j<n*2;j++){
            scanf("%d",&C[i][j]);
            Cline.push_back(C[i][j]);
        }
    }

    int P[n*2][n]={};
    vector<int> Pline;
    for(int i=0;i<n*2;i++){
        for(int j=0;j<n;j++){
            P[i][j]=C[i][j]+C[i][2*n-1-j];
            Pline.push_back(P[i][j]);
        }
    }

    sort(Cline.begin(),Cline.end());
    reverse(Cline.begin(),Cline.end());
    sort(Pline.begin(),Pline.end());
    reverse(Pline.begin(),Pline.end());

    ll ans;
    vector<ll> csum(Cline.size()), psum(Pline.size());
    partial_sum(Cline.begin(),Cline.end(),csum.begin());
    partial_sum(Pline.begin(),Pline.end(),psum.begin());

    ans = (cnt%2==0) ? max(csum[cnt-1],psum[cnt/2-1]+k) : csum[cnt-1];
    cout<< ans;

	return 0;
}
0