ural 1880. Psych Up's Eigenvalues 贪心

有3个人

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

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

Sample

input output
5
13 20 22 43 146
4
13 22 43 146
5
13 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 floats

if __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)





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值