10.2 校选拔赛

10.2 校选拔赛

B. Baby Bites

Arild just turned 11 year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has in a meal: every time he gets a bite, he will count it by saying the number out loud.

Unfortunately, talking while having a mouthful sometimes causes Arild to mumble incomprehensibly, making it hard to know how far he has counted. Sometimes you even suspect he loses his count! You decide to write a program to determine whether Arild’s counting makes sense or not.

Input
The first line of input contains an integer nn (1≤n≤10001≤n≤1000), the number of bites Arild receives. Then second line contains nn space-separated words spoken by Arild, the ii’th of which is either a non-negative integer aiai (0≤ai≤100000≤ai≤10000) or the string “mumble”.

Output
If Arild’s counting might make sense, print the string “makes sense”. Otherwise, print the string “something is fishy”.

Examples
Input
5
1 2 3 mumble 5
Output
makes sense
Input
8
1 2 3 mumble mumble 7 mumble 8
Output
something is fishy
Input
3
mumble mumble mumble
Output
makes sense

笔记

签到题,成功拿到一血。第一次拿一血,有点小开心。一眼押对了签到题。模拟,简单判断。

C. Code Cleanups

time limit per test1.0 s
memory limit per test256 MB
inputstandard input
outputstandard output
The management of the software company JunkCode has recently found, much to their surprise and disappointment, that productivity has gone down since they implemented their enhanced set of coding guidelines. The idea was that all developers should make sure that every code change they push to the master branch of their software repository strictly follows the coding guidelines. After all, one of the developers, Perikles, has been doing this since long before these regulations became effective so how hard could it be?

Rather than investing a lot of time figuring out why this degradation in productivity occurred, the line manager suggests that they loosen their requirement: developers can push code that weakly violates the guidelines as long as they run cleanup phases on the code from time to time to make sure the repository is tidy.

She suggests a metric where the “dirtiness” of a developer’s code is the sum of the pushes that violate the guidelines – so-called dirty pushes – made by that developer, each weighted by the number of days since it was pushed. The number of days since a dirty push is a step function that increases by one each midnight following the push. Hence, if a developer has made dirty pushes on days 11, 22, and 55, the dirtiness on day 66 is 5+4+1=105+4+1=10. She suggests that a cleanup phase, completely fixing all violations of the coding guidelines, must be completed before the dirtiness reaches 2020. One of the developers, Petra, senses that this rule must be obeyed not only because it is a company policy. Breaking it will also result in awkward meetings with a lot of concerned managers who all want to know why she cannot be more like Perikles? Still, she wants to run the cleanup phase as seldomly as possible, and always postpones it until it is absolutely necessary. A cleanup phase is always run at the end of the day and fixes every dirty push done up to and including that day. Since all developers are shuffled to new projects at the start of each year, no dirtiness should be left after midnight at the end of new year’s eve.

Input
The first line of input contains an integer nn (1≤n≤3651≤n≤365), the number of dirty pushes made by Petra during a year. The second line contains nn integers d1,d2,…,dnd1,d2,…,dn (1≤di≤3651≤di≤365 for each 1≤i≤n1≤i≤n) giving the days when Petra made dirty pushes. You can assume that di<djdi<dj for i<ji<j.

Output
Output the total number of cleanup phases needed for Petra to keep the dirtiness strictly below 2020 at all times.

Examples
inputCopy
5
1 45 65 84 346
outputCopy
4
inputCopy
3
310 330 350
outputCopy
3

笔记

也是模拟,读懂题意之后扫一遍就行。垃圾值<20,问倒垃圾次数。一开始数组就开了365,就一直WA,之后开到400就过了。新年前也得倒垃圾,就这个小问题,卡了一小时,不应该。

J. Jumbled String

time limit per test1.0 s
memory limit per test256 MB
inputstandard input
outputstandard output
Recall that a subsequence of a string is any string obtained by removing some subset of characters from the string, for instance “string”, “sing”, “i” and “sg” are all subsequences of “string”. If the same subsequence can be obtained in exactly tt different ways, by removing different subsets of characters, we say that the subsequence occurs tt times.

Jingfei wants to create a nonempty bit string that has the following properties:

the subsequence 00 occurs aa times,
the subsequence 01 occurs bb times,
the subsequence 10 occurs cc times, and
the subsequence 11 occurs dd times.
However, Jingfei does not know how to create such a string – or whether it is even possible. Could you help her?
Input
The input consists of a single line with four integers aa, bb, cc, and dd (0≤a,b,c,d≤1090≤a,b,c,d≤109).

Output
Output a bit string that satisfies the given requirements. If there are several solutions, output any one of them. If there are no solutions, output “impossible”.

Examples
inputCopy
3 4 2 1
outputCopy
01001
inputCopy
5 0 0 5
outputCopy
impossible

笔记

构造01序列,使得里面含有a个00,b个01,c个10,d个11。由a,d可以算得0,1的个数,先把0放好,再把1插进去,由b,c是否冲突判断有无冲突。各种特殊条件得考虑到,比较繁琐,这题我们也浪费了比较多的时间。

补题

H. House Lawn

time limit per test1.0 s
memory limit per test256 MB
inputstandard input
outputstandard output
You have just bought a new house, and it has a huge, beautiful lawn. A lawn that needs cutting. Several times. Every week. The whole summer.

After pushing the lawnmower around the lawn during the hottest Saturday afternoon in history, you decided that there must be a better way. And then you saw the ads for the new robotic lawnmovers. But which one should you buy? They all have different cutting speeds, cutting times and recharge times, not to mention different prices!

According to the advertisement, a robotic lawnmover will spend all its time either cutting the lawn or recharging its battery. Starting from a full battery, it will cut the lawn at a given rate of cc square meters per minute for a cutting time of tt minutes, after which it has run out of battery. Once out of battery, it will immediately start recharging. After recharging for rr minutes the battery is full again and it immediately starts cutting.

You decide that in order for your lawn to look sufficiently prim and proper, the lawnmower that you buy must be powerful enough to cut your whole lawn at least once a week on average. Formally, if we start the mower fully charged at the beginning of the week and run it for exactly TT weeks, it needs to cut the whole lawn at least TT times, for all positive integers TT. But apart from this, you have no specific requirements, so among the ones that satisfy this requirement, you will simply go for the cheapest option. For the purposes of cutting your lawn, you may make the simplifying assumption that a week is always exactly 1008010080 minutes long.

Input
The first line of input contains two integers ℓℓ and mm (1≤ℓ≤1061≤ℓ≤106, 1≤m≤1001≤m≤100), the size of your lawn in square meters, and the number of lawnmowers to consider, respectively.

Then follow mm lines, each containing a string nn and 44 integers pp, cc, tt, and rr, separated by commas, describing a lawnmower as follows:

nn is the name of the lawnmower, a string of at most 6060 printable characters (ASCII 3232 to 126126) excluding ‘,’, neither starting nor ending with a space,
1≤p≤1000001≤p≤100000 is the price of the lawnmover,
1≤c≤1001≤c≤100 is the cutting rate in square meters per minute,
1≤t≤100801≤t≤10080 is the cutting time in minutes, and
1≤r≤100801≤r≤10080 is the recharge time in minutes.
Output
Output the name of the cheapest lawnmower capable of cutting your whole yard at least once a week on average. If several lawnmovers share the same lowest price, output all of their names, in the same order they were given in the input. If there is no such mower, output “no such mower”.

Examples
inputCopy
7000 4
Grass Slayer 2000,9999,10,120,120
Slow-Mowe,999,1,120,240
Eco-cut X2,5499,2,25,35
Mowepower,5499,3,25,35
outputCopy
Eco-cut X2
Mowepower
inputCopy
100000 4
Grass Slayer 2000,9999,10,120,120
Slow-Mowe,999,1,120,240
Eco-cut X2,5499,2,25,35
Mowepower,5499,3,25,35
outputCopy
no such mower

笔记

比赛的时候一直WA,很绝望。我们一开始按照一周能割完并充满电就行来算的,但是WA了,我们就考虑是不是要考虑前N周,及最后可以充一部分电,下一周充一部分。然后改循环,超级难写,我还调爆炸了。之后看了题解,发现我们一开始推的公式是对的,只要考虑一周,但是整形的精度不够,要开到double就可以通过。

I. Intergalactic Bidding

time limit per test2.0 s
memory limit per test256 MB
inputstandard input
outputstandard output
Today the Intergalactic Council of Pebble Coins (ICPC) conducted an intergalactic auction of the Neutronium Chaos Pebble Coin (NCPC). This coin, which was forged in the Ancient Coin Machine (ACM), is rumored to be the key to ruling the universe.

Due to the extremely competitive nature of the auction, as well as the odd mechanics of the intergalactic currency used (far too advanced for mere mortals to understand), the auction was conducted with the following rules:

only one participant was allowed to make a bid at a time,
each participant was only allowed to make one bid, and
a participant making a bid had to bid at least twice the amount of the highest bid at the time.
The first participant making a bid was allowed to make a bid of any positive amount.
After the auction there were a lot of sore losers – understandably, having just lost their chance at world domination. To make the losers feel a little better and prevent possible rioting, the ICPC has decided to hold a lottery for the participants. The winners of the lottery are determined as follows. The ICPC picks a random number ss. A group of participants is called winning if the sum of their bets from the auction is equal to ss. A participant wins the lottery and receives a prize – a shiny Pebble Coin – if they belong to any winning group of participants.

Given the names of the participants, the bets that they made, and the random number ss chosen by the ICPC, help them determine which participants won the lottery.

Input
The first line of input contains two integers nn and ss, where 1≤n≤10001≤n≤1000 is the number of participants, and 1≤s<1010001≤s<101000 is the random number chosen by the ICPC.

Then follow nn lines describing the participants. Each line contains a string tt and an integer bb, where tt is the name of a participant, and 1≤b<1010001≤b<101000 is the amount of his bet. The name of each participant is unique and consists of between 11 and 2020 letters from the English alphabet.

Output
Output an integer kk denoting the number of participants that won the lottery. Then output kk lines containing the names of the participants that won the lottery, one per line, in any order.

Examples
inputCopy
5 63
Vader 3
Voldemort 7
BorgQueen 20
Terminator 40
Megatron 101
outputCopy
3
Terminator
BorgQueen
Vader
inputCopy
4 1112
Blorg 10
Glorg 1000
Klorg 1
Zlorg 100
outputCopy
0

笔记

比赛的时候没有想到后投标的是前面投标的最少两倍,就没能出好的算法……
其实就是一个贪心+高精度减法。从后往前减。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值