IT 개발자_S

해커랭크 Apple and Orange 본문

IT/알고리즘_Python

해커랭크 Apple and Orange

Soso12 2020. 3. 12. 21:51
반응형

#!/bin/python3

 

import math

import os

import random

import re

import sys

 

# Complete the countApplesAndOranges function below.

def countApplesAndOranges(s, t, a, b, apples, oranges):

    arrA =[]

    resultA =0

    arrO =[]

    resultB =0

    for i in range(len(apples)):

        arrA.append(a + apples[i])

        if(arrA[i] >= s and arrA[i] <=t): ## 파이썬 && and 조건

            resultA +=1

 

    for i in range(len(oranges)):

        arrO.append(b + oranges[i])

        if(arrO[i] >= s and arrO[i] <=t):

            resultB +=1

            

    print(resultA)

    print(resultB)

if __name__ == '__main__':

    st = input().split()

 

    s = int(st[0])

 

    t = int(st[1])

 

    ab = input().split()

 

    a = int(ab[0])

 

    b = int(ab[1])

 

    mn = input().split()

 

    m = int(mn[0])

 

    n = int(mn[1])

 

    apples = list(map(intinput().rstrip().split()))

 

    oranges = list(map(intinput().rstrip().split()))

 

    countApplesAndOranges(s, t, a, b, apples, oranges)

반응형

'IT > 알고리즘_Python' 카테고리의 다른 글

해커랭크 Breaking the Records  (0) 2020.03.22
해커랭크 Kangaroo PYTHON  (0) 2020.03.13
해커랭크 Grading Strudents  (0) 2020.03.12
해커랭크 TIME Conversion python  (0) 2020.03.12
해커랭크 Birthday Cake Candles  (0) 2020.03.10
Comments