#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n, a[100], b[100], minn = 99999999; int func(int suma, int sumb, int cnt ) { if (cnt + 1 == n) { //cout << "suma->" << suma << " sumb->" << sumb << " cnt->" << cnt << endl; suma = max(suma, sumb); minn = min(minn, suma); return 0; } func(suma + a[cnt+ 1], sumb, cnt+1); func(suma, sumb + b[cnt + 1], cnt+1); return 0; } int main() { int i, j, k; cin >> n; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; } func(a[0], 0, 0); func(0, b[0], 0); //cout << "minn->" << minn << endl; cout << minn << endl; getchar(); getchar(); return 0; }