Usaco JAN (Topic i)
I. Overview of the topic
Name of Chinese title |
Gift |
Delivery route |
Game Combination Technology |
Name of English title |
Gifts |
Delivery |
Combos |
Executable file name |
Gifts |
Delivery |
Combos |
Enter file name |
Gifts.in |
Delivery.in |
Combos.in |
Output file name |
Gifts.out |
Delivery.out |
Combos.out |
Time limit per test point |
1 seconds |
1 seconds |
1 seconds |
Number of test points |
10 |
10 |
10 |
Score per test point |
10 |
10 |
10 |
Comparison mode |
Full-text comparison |
Full-text comparison |
Full-text comparison |
Second, running memory limit
Running Memory caps |
M |
M |
M |
Note: Thank Lao Hu for his translation. "The error will be there, the statement is not so smooth ..."
1. gift {Bronze 1}
"Problem description"
FJ plans to send gifts to his N (1 <= n <= 1000) cattle with his B (1 <= b <= 1,000,000,000) Yuan budget.
The purchase of the gift of the first cow is spent P (i) yuan, the courier fee is S (i) Yuan. FJ has a coupon that can buy the same gift at half price, if it's always a gift I, then the total cost he spends on this gift is P (i)/2+s (i), coincidentally, p (i) must be an even number.
Please calculate how many cows fj can give gifts.
"File Input"
The first line, two integers, is n and b, respectively.
2nd.. N+1 lines, two integers per line, representing P (i) and S (i), respectively.
(0 <= P (i), S (i) <= 1,000,000,000).
"File Output"
An integer in which FJ can give gifts to as many cows as possible.
"Input Sample"
5 24
4 2
2 0
8 1
6 3
12 5
"Output Example"
4
"Sample description"
Buy 1 to 4 gifts, coupons for 3 use, (4+2) + (2+0) + (4+1) + (6+3) = 22, he can also use coupons at 1 or 4.
2. Fence paint {silver title 1}
"Problem description"
FJ has n (1 <= n <= 100) farms, each with a separate integer coordinate (x_i, y_i). He needed a distribution route, starting from the 1th farm, followed by farm 1, Farm 2, farm 3, and finally from farm N back to farm 1.
FJ can only walk in four directions each time, not walking a unit length of 1 minutes, in addition to farm 1, other farms can and can only be reached once.
Please calculate the minimum time spent on FJ.
"File Input"
The first line, an integer n.
2nd.. N+1 lines, two integers per line x_i and y_i (1 <= x_i, y_i <= 1,000,000).
"File Output"
A row, an integer that represents the minimum time spent. No solution is output-1.
"Input Sample"
4
2 2
2 4
2 1
1 3
"Output Example"
12
"Sample description"
FJ can complete his delivery route within 12 minutes: 2 minutes from the farm to 1 to 2 farms, 5 minutes from farm 2 to 3 farms (bypassing farm 1), 3 minutes to go from Farm 3 to farm 4, 2 minutes from farm 4 back to farm 1.
3. Game combination skill {Gold 1}
"Problem description"
Bessie is playing a game where only three skill keys "A" "B" "C" are available, but these keys can be used to form a specific combination of N (1 <= n<= 20). The first combination technique is represented by a string of length 1 to 15 s_i.
When Bessie entered a sequence of characters and a combination of techniques to match, he would get 1 points. Special, he entered a sequence of characters may be at the same time and a number of combinations of techniques, such as n=3, 3 combinations of "ABA", "CB", and "ABACB", Jobessi input "ABACB", he will get 3 points.
Jobessi input exactly K (1 <= k <= 1,000) characters, how many points can he get?
"File Input"
The first line, two integers n and K.
2nd.. N+1 lines, one string per line, represent a combination of techniques.
"File Output"
A row, an integer that represents the maximum score.
"Input Sample"
3 7
ABA
Cb
Abacb
"Output Example"
4
"Sample description"
Input Abacbcb,aba 1 points, ABACB 1 points, CB 2 points.
Usaco translation: Three Questions of Usaco (1)