if sorted(outlets) == required: solutions.append(sum(map(int,list(switchPosition)))) if solutions == []: return 'NOT POSSIBLE' else: return min(solutions) # Main if __name__ == '__main__': Problem(parser, solver, globals()).run()
iS = [] for s in [i for i, stal in enumerate(stals) if not stal]: iS.append(s) lS.append(LS(stals, s)) rS.append(RS(stals, s)) minLSRS = [min(lS[i], rS[i]) for i in xrange(len(iS))] maxLSRS = [max(lS[i], rS[i]) for i in xrange(len(iS))] minLSRSVal = max(minLSRS) i = minLSRS.index(minLSRSVal) if minLSRS.count(minLSRSVal) > 0: for j in xrange(len(iS)): if minLSRS[j] == minLSRSVal: if maxLSRS[j] > maxLSRS[i]: i = j stals[iS[i]] = 1 # print stals # print lS,rS ans = '{0} {1}'.format(max(lS[i], rS[i]), min(lS[i], rS[i])) print ans return ans # Main if __name__ == '__main__': with Timer('Problem C'): Problem(parser, solver).run()
from gcj.utils import Timer, getFunctions # Parser def parser(fin): data = fin.readFloats() return data # Solver def solver(data): C, F, X = data P = 2.0 T = 0.0 M = 0.0 while True: if X / P < (C / P + X / (P + F)): return '{0:.7f}'.format((T + X / P)) T += C / P P += F # Main if __name__ == '__main__': with Timer('Problem B'): Problem(parser, solver, getFunctions(globals())).run()