Input File: vasesin.txt
Output File: vasesout.txt
Time Limit: 1 second
Memory Limit: 1 GB
You have bought N identical flowers to arrange into three vases. As an expert in interior design, there are three important rules you must follow:
Your task is to determine a possible way to arrange the flowers. Note that there may be multiple possible solutions, or none at all.
The only line of input will contain a single integer: the number of flowers N.
Your program should output three space-separated integers, describing how many flowers to put into each vase. If there are multiple possible ways to arrange the flowers, any will do.
If it is impossible to place flowers according to the rules, print 0 0 0 instead.
Input File: rpsin.txt
Output File: rpsout.txt
Time Limit: 1 second
Memory Limit: 1 GB
‰C Rock. Paper. Scissors. The rules are simple. The game is contested by two people over N rounds. During each round, you and your opponent simultaneously throw either Rock, Paper or Scissors. Rock beats Scissors, Scissors beats Paper, and Paper beats Rock. If your throw beats your opponent’s, you gain one point. Conversely, if their throw beats yours, you lose one point.
Your opponent is very predictable. You know that they will throw Rock in the first Ra rounds, throw Paper in the next Pa rounds, then finally throw Scissors in the last Sa rounds, where Ra + Pa + Sa = N.
You will throw Rock in Rb rounds, Paper in Pb rounds, and Scissors in Sb rounds, where Rb + Pb + Sb = N. However, as you are an experienced player, you may throw these in any order you like.
At the beginning of the game, you start with 0 points. What is the maximum number of points you can finish with?
Your program should output a single integer: the maximum number of points you could score after all N rounds have been played. Note that this number may be positive, negative, or zero.
Input File: hirein.txt
Output File: hireout.txt
Time Limit: 1 second
Memory Limit: 1 GB
High up in the peaks of Kosciuszko National Park, an elite sect of monks are deciding how to assign jobs to the new monks.
They have hired N new monks, numbered from 1 to N, each possessing a possibly different skill level. The monk i has a skill level of xi.
There are S student jobs available, numbered from 1 to S, created for monks to learn from their masters. As such, there is a limit on how much skill a monk can have for this job. Student job j is available to monks with a skill level at most sj.
There are M master jobs available, numbered from 1 to M, created for monks to teach their students. As such, there is a minimum skill level a monk must have for this job. Master job k is available to monks with a skill level at least mk.
Each monk can be assigned at most one job, and each job can be assigned to at most one monk. What is the largest number of monks you can assign to jobs?
Your program should output a single integer: the maximum number of monks who can be assigned to jobs.
Input File: snakein.txt
Output File: snakeout.txt
Time Limit: 1 second
Memory Limit: 1 GB
After the success of your latest research project in mythical DNA, you have gained the attention of a most diabolical creature: Medusa.
Medusa has snakes instead of hair. Each of her snakes' DNA is represented by an uppercase string of letters. Each letter is one of S, N, A, K or E.
Your extensive research shows that a snake's venom level depends on its DNA. A snake has venom level x if its DNA:
For example, a snake with venom level 1 has DNA SNAKE, while a snake that has venom level 3 has DNA SSSNNNAAAKKKEEE. If a snake's DNA does not fit the format described above, it has a venom level of 0.
Medusa would like your help making her snakes venomous, by deleting zero or more letters from their DNA. Given a snake's DNA, can you work out the maximum venom level this snake could have?
The first line contains the integer N: the number of letters in the snake's DNA. The second line contains a string of N uppercase letters, representing the snake's DNA. Each letter is one of S, N, A, K or E.
Your program should output a single integer: the maximum venom level the snake could have, after you delete some (possibly none) of the letters from its DNA.
Input File: evadingin.txt
Output File: evadingout.txt
Time Limit: 1 second
Memory Limit: 1 GB
It is the year 2077, when androids live among us, cars no longer have wheels and humans are born on blockchain. You are preparing to pull off the greatest heist of all time: stealing the Bitcoin. Stealing the Bitcoin is the easy part; evading capture is much harder.
The world consists of N cities, numbered from 1 to N. E pairs of these cities are adjacent to each other. In a single hop, you can travel from the city you are currently in to any adjacent city.
Your heist will begin in city X where the Bitcoin is located. After stealing the Bitcoin, you will need to make exactly K hops to be safe from capture (too few and the Chaser will catch you, too many and the All-Seeing I will know where you are).
You aren't yet sure which hops you will make on the day of the heist, so you have decided to work out the number of different cities you could finish in after making exactly K hops. You whip out your trusty laptop and begin coding.
The first line contains the integers N, E, X and K, which are the number of cities, the number of adjacent pairs of cities, the starting city and the number of hops you must make, respectively.
Then E lines follow, describing the adjacent pairs of cities. The ith of these lines contains ai and bi, indicating that city ai is adjacent to city bi.
Your program should output a single integer, the number of different cities you could finish in after making exactly K hops. You are guaranteed that at least one such sequence of hops exists.
Input File: lscin.txt
Output File: lscout.txt
Time Limit: 1 second
Memory Limit: 1 GB
The grand opening of Lollipops, Sweets and Chocolates (LSC) was a great success! Since then a total of N LSC stores have opened along Australian Ice-cream and Oreo Crescent (AIOC), the most candilicious street in Sydney.
The street is divided into L blocks, spaced 1 metre apart. The blocks are labelled with numbers from 1 to L along the street, so that the distance between any two blocks a and b is |a - b| metres.
Each of the N stores occupies a different block. There are also M houses along the street, each occupying a different block. However, houses and stores may occupy the same block!
To keep the little boys and girls of Sydney excited about the stores, LSC has been distributing personalised pamphlets to the houses on the street. There is one pamphlet for each house. The ith pamphlet contains a message of the form:
There are si stores within walking distance of your house!
Wondering how far you have to walk to get your hands on another mouthwatering chlorosulfonic acid sorbet, you decide to investigate how far ‘walking distance’ could be. Walking distance means a distance of at most R metres, and you would like to determine a possible value for R. You know that the street is very long, so R cannot be greater than L.
You have collected all M pamphlets, but in your haste you have forgotten which house each pamphlet came from! Given all the numbers on the pamphlets, your task is to determine a possible value of R. LSC is notorious for distributing inaccurate pamphlets, so it is also possible that no such value of R exists.
Your program must output a single integer (whole number): a possible value of R, or −1 if no such value exists. If there are multiple possible answers, output any one of them. Note that the value of R must not be greater than L.
© 2024. All Rights Reserved. 沪ICP备2023009024号-1