Bzoj 1027[jsoi2007] Alloy-Floyd + Convex bag

Source: Internet
Author: User

1027: [JSOI2007] Alloy time limit:4 Sec Memory limit:162 MB
Description

A company processes an alloy consisting of iron, aluminum, and tin. Their work is very simple. First of all, the import of some Fe-al-SN alloy raw materials, different types of
The proportion of Fe, AL and SN in raw materials is different. Then, each raw material is taken out of a certain amount, after melting, mixing, to obtain a new alloy. New alloys of iron and aluminum
The proportion of the tin to the user needs. Now, the user gives the n kinds of alloys they need, and the proportion of Fe-al-sn in each alloy. The company hopes to
To order a minimum variety of raw materials, and use these raw materials to produce all the types of alloys required by the user.

Input

The first line is two integers m and n (M, n≤500), which represent the number of raw materials and the number of alloy species required by the user, respectively. 2nd to M + 1 lines, three per row
A, B, C (A, B, c≥0 and A + b + c = 1), respectively, representing the proportion of Fe-al-Sn in a raw material. Section M + 2 to M +
n + 1 lines, three reals per row, A, B, C (A, B, c≥0 and A + b + c = 1), respectively, in a user-required alloy
The proportion of the total.

Output

An integer that represents the minimum number of raw material species required. If there is no solution, the output –1.

Sample Input10 10
0.1 0.2 0.7
0.2 0.3 0.5
0.3 0.4 0.3
0.4 0.5 0.1
0.5 0.1 0.4
0.6 0.2 0.2
0.7 0.3 0
0.8 0.1 0.1
0.9 0.1 0
1 0 0
0.1 0.2 0.7
0.2 0.3 0.5
0.3 0.4 0.3
0.4 0.5 0.1
0.5 0.1 0.4
0.6 0.2 0.2
0.7 0.3 0
0.8 0.1 0.1
0.9 0.1 0
1 0 0
Sample Output5I'm a konjac konjac, too divine.This problem can be translated into a geometric model for any two points, if we put their first two materials of the gravity as the x-axis and y-axis coordinates, then they can be synthesized by the proportion of the corresponding point on the line x, y so if it is multiple points, can be synthesized in the range of the convex hull (can be mended) So if all the required material points are on the left side of the two-point segment, we can have a 1-point edge at these two points so that the most short-circuiting can be surrounded by a few special sentences: 1, all points are the same 2, all points are in a line segment.

Bzoj 1027[jsoi2007] Alloy-Floyd + Convex bag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.