Skip to content

Instantly share code, notes, and snippets.

@jakab922
Last active December 10, 2015 10:59
Show Gist options
  • Save jakab922/bb03019b9d5a4e27426d to your computer and use it in GitHub Desktop.
Save jakab922/bb03019b9d5a4e27426d to your computer and use it in GitHub Desktop.
Solution for Freelancer's dream on codeforces(http://codeforces.com/contest/606/problem/E)
""" The problem is an extremely easy linear programming problem.
The only issue is that there is no simplex solver in the
standard library and scipy is not available on codeforces.
"""
from scipy.optimize import linprog
n, p, q = map(int, raw_input().strip().split())
A = [[], []]
b = [-p, -q]
c = [1 for _ in xrange(n)]
for _ in xrange(n):
ai, bi = map(int, raw_input().strip().split())
A[0].append(-ai)
A[1].append(-bi)
bounds = [(0, None) for _ in xrange(n)]
options = {
"bland": True,
"tol": 1e-15
}
res = linprog(c, A_ub=A, b_ub=b, bounds=bounds, options=options)
print res.fun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment