백준/문제풀이_python

262624 빅데이터? 정보보호! python

휴대용치즈 2022. 12. 17. 21:35

https://www.acmicpc.net/problem/26264

 

26264번: 빅데이터? 정보보호!

첫 번째 줄에 정보보호 분야보다 빅데이터 분야에 관심이 있는 학생이 더 많으면 "bigdata?"를, 빅데이터 분야보다 정보보호 분야에 관심이 있는 학생이 더 많으면 "security!"를, 같으면 "bigdata? securit

www.acmicpc.net

서울 사이버 대학을 다니고~ 나의 성공시대 시작했다~

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

문제 접근

count를 쓰면 되는데 느린줄 알고 7자리와 8자리로 다른점을 사용했다.

s로 시작하면 +8, b로 시작하면 +9를 하면서 배열의 위치를 옮겨갔다.

하지만 count를 쓰는게 더 빠르다...

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

나의 코드

import sys
input = sys.stdin.readline

"""
나의 성공시대 시작됐다 A번


"""

N = int(input())
memo = input().rstrip()
ans = 0
i = 0
for _ in range(N):
    if memo[i]=='s':
        ans += 1
        i+=8
    else:
        ans -= 1
        i+=7

if ans>0:
    print("security!")
elif ans<0:
    print("bigdata?")
else:
    print("bigdata? security!")

31940KB 84ms

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

수정

N = int(input())
str = input()
a = str.count('security')
b = str.count('bigdata')

if(a > b):
    print('security!')
elif(a < b):
    print('bigdata?')
else :
    print('bigdata? security!')