ural 1880. Psych Up's Eigenvalues 贪心

来源:互联网 发布:微机原理接口编程题 编辑:程序博客网 时间:2024/06/06 16:38

有3个人

每个人有n个特征值(1 ≤ n ≤ 4 000)

求每个人都有的特征值有几个?(特征值 ≤ 10^9)

Sample

inputoutput
513 20 22 43 146413 22 43 146513 43 67 89 146
3
Problem Author: Denis Mukhametianov
Problem Source: Ural Regional School Programming Contest 2011
class InputReader():    def nextInt(self):        return  int(input().strip())    def nextLine(self):        return input()    def nextString(self):        return input().strip()    def nextInts(self):        ints = []        str = input().strip().split()        for s in str:            if (s is None) or (len(s) == 0):                continue            ints.append(int(s))        return ints    def nextFloats(self):        floats = []        str = input().strip().split()        for s in str:            if (s is None) or (len(s) == 0):                continue            floats.append(float(s))        return floatsif __name__ == '__main__':    reader = InputReader()    an = reader.nextInt() ;    a = reader.nextInts() ;    bn = reader.nextInt();    b = reader.nextInts();    cn = reader.nextInt();    c = reader.nextInts();    i = 0    j = 0    k = 0    sum = 0    while i < an and j < bn and k < cn :        if a[i] == b[j] and a[i] == c[k]:            sum += 1        id = 0        mi = a[i]        if mi > b[j]:            mi = b[j]            id = 1        if mi > c[k]:            mi = c[k]            id = 2        if id == 0 :            i += 1        elif id == 1:            j += 1        else:            k += 1    print(sum)