結果

問題 No.2094 Symmetry
ユーザー CleyLCleyL
提出日時 2022-12-30 11:11:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 962 ms
コンパイル使用メモリ 84,552 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-05-04 02:10:09
合計ジャッジ時間 8,233 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 155 ms
9,092 KB
testcase_10 AC 156 ms
9,092 KB
testcase_11 AC 157 ms
9,088 KB
testcase_12 AC 157 ms
9,092 KB
testcase_13 AC 144 ms
7,428 KB
testcase_14 AC 156 ms
9,092 KB
testcase_15 AC 156 ms
9,036 KB
testcase_16 AC 157 ms
9,216 KB
testcase_17 AC 144 ms
7,428 KB
testcase_18 AC 145 ms
7,428 KB
testcase_19 AC 159 ms
8,968 KB
testcase_20 AC 157 ms
9,096 KB
testcase_21 AC 155 ms
8,964 KB
testcase_22 AC 154 ms
9,088 KB
testcase_23 AC 147 ms
7,424 KB
testcase_24 AC 145 ms
7,424 KB
testcase_25 AC 156 ms
9,092 KB
testcase_26 AC 156 ms
9,216 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 15 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 15 ms
5,376 KB
testcase_31 AC 132 ms
9,092 KB
testcase_32 AC 141 ms
9,092 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 103 ms
9,088 KB
testcase_35 AC 86 ms
9,092 KB
testcase_36 AC 79 ms
7,428 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