結果
| 問題 | No.771 しおり | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-05-12 08:14:20 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 199 ms / 2,000 ms | 
| コード長 | 517 bytes | 
| コンパイル時間 | 2,675 ms | 
| コンパイル使用メモリ | 194,504 KB | 
| 最終ジャッジ日時 | 2025-01-10 10:42:11 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 43 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         int n; scanf("%d",&n);
      |                ~~~~~^~~~~~~~~
main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         rep(i,n) scanf("%d%d",&a[i],&b[i]);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int INF=1<<29;
int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);
	static int dp[1<<18][18];
	rep(S,1<<n) rep(i,n) dp[S][i]=INF;
	rep(i,n) dp[1<<i][i]=0;
	rep(S,1<<n) rep(i,n) if(dp[S][i]<INF) {
		rep(j,n) if((S>>j&1)==0) {
			dp[S|(1<<j)][j]=min(dp[S|(1<<j)][j],max(dp[S][i],b[i]-a[i]+a[j]));
		}
	}
	printf("%d\n",*min_element(dp[(1<<n)-1],dp[(1<<n)-1]+n));
	return 0;
}
            
            
            
        