#include <iostream>
using namespace std;
int ans = 999999999;
int n, t1[20], t2[20], end = 0;
bool b[20];
void f(int step, int k, int sum)
{
if (step > n)
{
if (ans > sum + t2[k]) ans = sum + t2[k];
return;
}
for (int i = 1; i <= n; i ++ )
{
if (!b[i])
{
b[i] = true;
f(step + 1, i, sum + max(t2[k], t1[i]));
b[i] = false;
}
}
}
int main(void)
{
cin >> n;
for (int i = 1; i <= n; i ++ ) cin >> t1[i] >> t2[i];
f(1, 1, 0);
cout << ans;
return 0;
}
共 1 条回复
是啥?