전체 글439 백준 1021번 파이썬 N,M = map( int, input().split())a=[j for j in range(1,N+1)]location = list(map(int, input().split()))count=0for i in range(len(location)): r=[0]*len(a) left=0 right=0 if a[0] == location[i]: del a[0] else: for k in range(len(a)): r[k]=a[k] while r[0] !=location[i]: r.insert(0,r[-1]) del r[-1] right+=1 l=a while a[0] != location[i]: a.append(a[0]) del a[0] left += 1 if right>=left: count=count+le.. 2018. 9. 18. 백준 10866번 파이썬 num = int(input())a=[]for i in range(num): cmd = input().split() if cmd[0] == 'push_front': a.insert(0,cmd[1]) elif cmd[0] == 'push_back': a.append(cmd[1]) elif cmd[0] == 'pop_front': if len(a)!=0: print(a.pop(0)) else: print(-1) elif cmd[0] == 'pop_back': if len(a)!=0: print(a.pop(-1)) else: print(-1) elif cmd[0] == 'size': print(len(a)) elif cmd[0] == 'empty': if len(a) ==0: print(1) else: pri.. 2018. 9. 18. 백준 8958번 파이썬 num = int(input())for i in range(num): score=0 index=0 result = list(input()) while index< len(result): flag=0 sum=0 while (index 2018. 9. 18. 백준 12069번 파이썬 a,b = map(int, input().split())list = [i for i in range(1,(a+1))]ans=[0]*aindex=0delete = b-1while (len(list)!=0): while delete >= len(list): delete = delete - len(list) ans[index] = list[delete] del list[delete] delete =delete + (b-1) index+=1 print("") else: print(ans[i],end=", ") 2018. 9. 17. 이전 1 ··· 98 99 100 101 102 103 104 ··· 110 다음