結果

問題 No.2094 Symmetry
ユーザー CleyLCleyL
提出日時 2022-12-30 11:11:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 84,216 KB
実行使用メモリ 9,212 KB
最終ジャッジ日時 2023-08-16 18:36:24
合計ジャッジ時間 8,417 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 147 ms
8,892 KB
testcase_10 AC 144 ms
8,944 KB
testcase_11 AC 143 ms
8,916 KB
testcase_12 AC 145 ms
8,868 KB
testcase_13 AC 134 ms
7,108 KB
testcase_14 AC 144 ms
9,040 KB
testcase_15 AC 142 ms
8,988 KB
testcase_16 AC 143 ms
8,952 KB
testcase_17 AC 130 ms
7,072 KB
testcase_18 AC 131 ms
7,036 KB
testcase_19 AC 145 ms
8,988 KB
testcase_20 AC 144 ms
8,872 KB
testcase_21 AC 144 ms
8,868 KB
testcase_22 AC 143 ms
9,212 KB
testcase_23 AC 133 ms
7,120 KB
testcase_24 AC 133 ms
7,076 KB
testcase_25 AC 142 ms
8,988 KB
testcase_26 AC 143 ms
9,212 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 13 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 13 ms
4,380 KB
testcase_31 AC 121 ms
9,088 KB
testcase_32 AC 129 ms
8,896 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 91 ms
8,992 KB
testcase_35 AC 77 ms
8,932 KB
testcase_36 AC 71 ms
7,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  long long n,k;cin>>n>>k;
  int b = 0;
  for(int i = 0; 2*n > i; i++){
    for(int j = 0; 2*n > j; j++){
      char c;cin>>c;
      if(c == '#')b++;
    }
  }
  if(b == 0){
    cout << k << endl;
    return 0;
  }
  vector<vector<long long>> A(2*n,vector<long long>(2*n));
  vector<long long> B;
  for(int i = 0; 2*n > i; i++){
    for(int j = 0; 2*n > j; j++){
      cin>>A[i][j];
      B.push_back(A[i][j]);
    }
  }
  sort(B.begin(),B.end(),greater<long long>());
  long long ans = 0;
  for(int i = 0; b > i; i++){
    ans += B[i];
  }
  if(b%2 == 0){
    long long tmp = k;
    vector<long long> C;
    for(int i = 0; 2*n > i; i++){
      for(int j = 0; n > j; j++){
        C.push_back(A[i][j]+A[i][2*n-j-1]);
      }
    }
    sort(C.begin(),C.end(),greater<long long>());
    for(int i = 0; b/2 > i; i++){
      tmp += C[i];
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}
0