結果
問題 |
No.771 しおり
|
ユーザー |
|
提出日時 | 2025-07-01 16:06:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 629 bytes |
コンパイル時間 | 1,638 ms |
コンパイル使用メモリ | 195,252 KB |
実行使用メモリ | 20,168 KB |
最終ジャッジ日時 | 2025-07-01 16:06:50 |
合計ジャッジ時間 | 8,716 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 42 |
ソースコード
#include<bits/stdc++.h> using namespace std; int N,A[18],B[18]; int cost[18][18],dp[1<<18]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; for(int i=0;i<N;i++)cin>>A[i]>>B[i]; for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(i!=j){ cost[i][j]=B[i]-A[i]+A[j]; } for(int i=0;i<1<<N;i++)dp[i]=2e9; for(int i=0;i<N;i++){ dp[1<<i]=0; for(int j=0;j<1<<N;j++)if(dp[j]<(int)2e9){ for(int k=0;k<N;k++)if(j>>k&1){ for(int l=0;l<N;l++)if(!(j>>l&1)){ dp[j|1<<l]=min(dp[j|1<<l],max(dp[j],cost[k][l])); } } } } cout<<dp[(1<<N)-1]<<'\n'; return 0; }