CSP期末预测之最佳阈值——python版

m = input()
y = []
result = []
dic = dict()
def predict(y,seita):
    if y < seita:
        return 0
    else:
        return 1

def getkey(dic,maxvalue):
    dic = dict(dic)
    indexs = []
    for key,value in dic.items():
        if value == maxvalue:
            indexs.append(key)
    return max(indexs)


for i in range(int(m)):
    y_,result_ = input().split()
    y_ = int(y_)
    result_ = int(result_)
    y.append(y_)
    result.append(result_)
    if y_<0 or y_>10**8:
        pass

for seita in y:
    count = 0
    for index,yi in enumerate(y):
        if predict(yi,seita) == result[index]:
            count = count + 1
    dic[seita] = count

print(getkey(dic,max(dic.values())))


上一篇:算法中的那些骚操作


下一篇:路径显示不下时,中间显示省略号