天天看点

Google Code jam Qualification Round 2015 --- Problem A. Standing OvationProblem A. Standing Ovation  Problem's Link:   https://code.google.com/codejam/contest/6224486/dashboard#s=p0

Mean: 

题目说的是有许多观众,每个观众有一定的羞涩值,只有现场站起来鼓掌的人数达到该值才会站起来鼓掌,问最少添加多少羞涩值任意的人,才能使所有人都站起来鼓掌。

analyse:

贪心模拟一下,从前往后扫一遍就行。

Time complexity: O(n)

Source code: 

Google Code jam Qualification Round 2015 --- Problem A. Standing OvationProblem A. Standing Ovation  Problem's Link:   https://code.google.com/codejam/contest/6224486/dashboard#s=p0
Google Code jam Qualification Round 2015 --- Problem A. Standing OvationProblem A. Standing Ovation  Problem's Link:   https://code.google.com/codejam/contest/6224486/dashboard#s=p0

View Code

继续阅读