코딩

[ 백준 ]1966 프린터 큐

알파세 2018. 3. 14. 17:15

이번에 파이썬을 공부를 해봐야 할것 같아서 백준 문제를 풀게 되었습니다.


그렇게 알고리즘 코딩에 뛰어난게 아니지만


조금씩이라도 정진하면 어느새 자유자재로 쓰는 내 자신을 마주볼것을 기대하면서^^;


객체를 써서 좀더  이쁘고 깔끔하게 풀고 싶었지만 결국 반만 활용했습니다.


하지만 처음으로 파이썬 객체를 만들어본것에 의의를 두고 ^^ㅎ




class paper:
    def __init__(self,important):
        self.important = important
    def setPaper(self,seq,important):
        self.important =important
        
def remove_insert(list):
    temp = list.pop(0)
    list.append(temp)
    #printList(list)

def findMax(list,present):
    for i in list: 
        if(present.important < i.important ):
            return True
    return False

testCase = input()
maxNum  =0 
list = [] 

for t in range(0,int(testCase)):
    count = 0
    while(len(list) > 0):
        list.pop()
        
    n,m= input().split()
    str = input().split()
    pointer = ""
    
    for i in str:
        p =  paper(i)
        list.append(p)
     
    pointer = list[int(m)]
    
    
    while(len(list) > 0):
        present = list[0]    

        if ( findMax(list, present) ) : 
            remove_insert(list)
        else:
            count+=1
            if( present == pointer ):
                print(count)
                break 
            list.pop(0)