def parse(inFile):
return inFile.getInts()[1:]
def solve(scores):
points = [z for z in scores]
total = float(sum(points))
N = len(points)
qual = (2 * total) / N
alreadyqual = 0
while (len([score for score in points if score > qual]) > 0):
qs = [score for score in points if score > qual]
alreadyqual += sum(qs)
points = [score for score in points if score <= qual]
N = len(points)
qual = (2 * total - alreadyqual) / N
return " ".join(["%.6f" % (((qual - score) * 100 / total) if (qual > score) else 0) for score in scores])
if __name__ == "__main__":
from GCJ import GCJ
GCJ(parse, solve, "/Users/lpebody/gcj/2012_1b/", "a").run()
ZGVmIHBhcnNlKGluRmlsZSk6CiAgICByZXR1cm4gaW5GaWxlLmdldEludHMoKVsxOl0KCmRlZiBzb2x2ZShzY29yZXMpOgogICAgcG9pbnRzID0gW3ogZm9yIHogaW4gc2NvcmVzXQogICAgdG90YWwgPSBmbG9hdChzdW0ocG9pbnRzKSkKICAgIE4gPSBsZW4ocG9pbnRzKQogICAgcXVhbCA9ICgyICogdG90YWwpIC8gTgogICAgYWxyZWFkeXF1YWwgPSAwCiAgICB3aGlsZSAobGVuKFtzY29yZSBmb3Igc2NvcmUgaW4gcG9pbnRzIGlmIHNjb3JlID4gcXVhbF0pID4gMCk6CiAgICAgICAgcXMgPSBbc2NvcmUgZm9yIHNjb3JlIGluIHBvaW50cyBpZiBzY29yZSA+IHF1YWxdCiAgICAgICAgYWxyZWFkeXF1YWwgKz0gc3VtKHFzKQogICAgICAgIHBvaW50cyA9IFtzY29yZSBmb3Igc2NvcmUgaW4gcG9pbnRzIGlmIHNjb3JlIDw9IHF1YWxdCiAgICAgICAgTiA9IGxlbihwb2ludHMpCiAgICAgICAgcXVhbCA9ICgyICogdG90YWwgLSBhbHJlYWR5cXVhbCkgLyBOCiAgICByZXR1cm4gIiAiLmpvaW4oWyIlLjZmIiAlICgoKHF1YWwgLSBzY29yZSkgKiAxMDAgLyB0b3RhbCkgaWYgKHF1YWwgPiBzY29yZSkgZWxzZSAwKSBmb3Igc2NvcmUgaW4gc2NvcmVzXSkKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICBmcm9tIEdDSiBpbXBvcnQgR0NKCiAgICBHQ0oocGFyc2UsIHNvbHZlLCAiL1VzZXJzL2xwZWJvZHkvZ2NqLzIwMTJfMWIvIiwgImEiKS5ydW4oKQo=