The problem is from codeforces: http://www.codeforces.com/problemset/problem/158/A
It is summer. The temperature today in Sheffield is 25 degree. I got to say, I feel a bit sleepy in the afternoon. Therefore, getting ‘accepted’ will definitely cheer me up :).
This problem is also simple. Actually, most of the ‘A’ problems (usually the first one) in codeforces contests are easy to solve. I choose these problems to boost my confidences 🙂 and learn python.
The problem is even easier. Because the array is already sorted in non-asending order. The answer is to count how many integers (positive, of course) are greater than the array item arr[k – 1] (zero-based array)
The python solution is presented and it is accepted for the first time.
s = raw_input().split(" ") n = int(s[0]) k = int(s[1]) s = raw_input().split(" ") s = map(int, s) ans = 0 for i in s: if i > 0 and i >= s[k - 1]: ans += 1 print ans
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Codeforces: A. String Task
Next Post: The github experience