結果
問題 |
No.2094 Symmetry
|
ユーザー |
|
提出日時 | 2022-12-23 00:00:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 866 bytes |
コンパイル時間 | 2,189 ms |
コンパイル使用メモリ | 203,128 KB |
最終ジャッジ日時 | 2025-02-09 18:40:02 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); long long N,K; cin>>N>>K; int cnt=0; for(int i=0;i<N*2;i++){ for(int j=0;j<N*2;j++){ char c; cin>>c; cnt+=c=='#'; } } vector<vector<int>>C(N*2,vector<int>(N*2)); for(int i=0;i<N*2;i++)for(int j=0;j<N*2;j++)cin>>C[i][j]; vector<int>t; long long ans=0; for(int i=0;i<N*2;i++){ for(int j=0;j<N*2;j++)t.push_back(C[i][j]); } sort(t.begin(),t.end(),greater<int>()); for(int i=0;i<cnt;i++){ ans+=t[i]; } if(cnt%2==0){ t.clear(); long long ans2=K; for(int i=0;i<N*2;i++){ for(int j=0;j<N;j++){ t.push_back(C[i][j]+C[i][N*2-j-1]); } } sort(t.begin(),t.end(),greater<int>()); for(int i=0;i<cnt/2;i++)ans2+=t[i]; ans=max(ans,ans2); } cout<<ans<<'\n'; }