結果
問題 | No.2261 Coffee |
ユーザー |
![]() |
提出日時 | 2023-04-07 21:48:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 467 ms / 2,000 ms |
コード長 | 854 bytes |
コンパイル時間 | 2,042 ms |
コンパイル使用メモリ | 171,568 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2024-10-02 19:22:00 |
合計ジャッジ時間 | 12,194 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll =long long;#define all(v) v.begin(),v.end()#define rep(i,a,b) for(int i=a;i<b;i++)#define rrep(i,a,b) for(int i=a;i>=b;i--)int main() {ll N;cin>>N;vector<vector<ll>> vec(N,vector<ll> (5));for(ll i=0;i<N;i++) {for(ll j=0;j<5;j++) cin>>vec[i][j];}vector<ll> note((1LL<<5),-1000000000000000);for(ll i=0;i<(1LL<<5);i++) {for(ll j=0;j<N;j++) {ll count=0;for(ll h=0;h<5;h++) {if(i&(1LL<<h)) count-=vec[j][h];else count+=vec[j][h];}note[i]=max(note[i],count);}}for(ll i=0;i<N;i++) {ll ans=0;for(ll j=0;j<(1LL<<5);j++) {ll count=0;for(ll h=0;h<5;h++) {if(j&(1LL<<h)) count-=vec[i][h];else count+=vec[i][h];}ll t=(1LL<<5)-1;t^=j;ans=max(ans,count+note[t]);}cout<<ans<<endl;}}