結果
問題 | No.943 取り調べ |
ユーザー |
|
提出日時 | 2019-12-09 00:34:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 185 ms / 1,206 ms |
コード長 | 529 bytes |
コンパイル時間 | 600 ms |
コンパイル使用メモリ | 63,656 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-02 22:28:43 |
合計ジャッジ時間 | 2,512 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N; int X[20],A[20]; main() { cin>>N; for(int i=0;i<N;i++) { for(int j=0;j<N;j++) { int x; cin>>x; X[i]|=x<<j; } } for(int i=0;i<N;i++)cin>>A[i]; int ans=2e9; for(int i=0;i<1<<N;i++) { int out=0; for(int ccc=0;ccc<N;ccc++) { for(int j=0;j<N;j++) { if((X[j]&~(out|i))==0)out|=1<<j; } } if(!(((1<<N)-1)&~out)) { int now=0; for(int j=0;j<N;j++)if(i>>j&1)now+=A[j]; if(ans>now)ans=now; } } cout<<ans<<endl; }