Skip to content

Commit 45f5ce3

Browse files
authored
hsy scofe2 (#50)
* 5557 * 16953 * 1012 * 2644 * 11909 * 11909,11909-2 fix * 그래프 이론 실전문제 * 스타트업 코딩 페스티벌 1차 * 5,6 * scofe2 * .ds_store
1 parent 004b35d commit 45f5ce3

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed

‎.DS_Store‎

6 KB
Binary file not shown.

‎syheo/.DS_Store‎

0 Bytes
Binary file not shown.

‎syheo/codingTest1/.DS_Store‎

0 Bytes
Binary file not shown.

‎syheo/codingTest1/scofe2/1.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
import sys
3+
input = sys.stdin.readline
4+
5+
N, time = map(str,input().split())
6+
N = int(N)
7+
h = int(time[0:2])
8+
m = int(time[3:5])
9+
s = int(time[6:8])
10+
times = h*60*60+ m*60 + s
11+
12+
timeList = [0 for _ in range(N)]
13+
dp= [0 for _ in range(N+1)]
14+
15+
maxSongIdx= -1
16+
maxSong=-1
17+
#플레이리스트 입력
18+
for i in range(N):
19+
tmp = input()
20+
timeList[i]=int(tmp[0:2])*60+int(tmp[3:5])
21+
22+
start = 0
23+
sum = 0
24+
cnt = 0
25+
for i in range(N):
26+
sum+=timeList[i]
27+
cnt+=1
28+
if sum >=times:
29+
if maxSong<cnt:
30+
maxSong = cnt
31+
maxSongIdx = start
32+
while sum>=times:
33+
sum-=timeList[start]
34+
start+=1
35+
cnt -= 1
36+
37+
38+
print(maxSong,maxSongIdx+1,end=' ')

‎syheo/codingTest1/scofe2/2.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sys
2+
sys.setrecursionlimit(10**7)
3+
input = sys.stdin.readline
4+
5+
N = int(input())
6+
7+
def find_path(last,visited):
8+
if visited == (1<<n)-1:
9+
return info[country[last]][0] or INF
10+
if DP[last][visited] is not None:
11+
return DP[last][visited]
12+
tmp=INF
13+
for city in range(n):
14+
if visited & (1 << city) == 0 and info[country[last]][city] != 0:
15+
tmp=min(tmp,find_path(city,visited|(1<<city)) + info[country[last]][city])
16+
DP[last][visited]=tmp
17+
return tmp
18+
19+
country = []
20+
info = dict()
21+
INF = int(10000)
22+
23+
for i in range(N):
24+
c1, c2,cost = map(str,input().split())
25+
if c1 not in info.keys():
26+
country.append(c1)
27+
info[c1]=[0 for _ in range(6)]
28+
if c2 not in info.keys():
29+
country.append(c2)
30+
info[c2]=[0 for _ in range(6)]
31+
info[c1][country.index(c2)]=int(cost)
32+
info[c2][country.index(c1)]=int(cost)
33+
n = len(country)
34+
35+
DP=[[None]*(1<<n) for _ in range(n)]
36+
37+
38+
print(find_path(0,1<<0))
39+
40+
41+
42+
43+

‎syheo/codingTest1/scofe2/4.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import re
2+
3+
N = int(input())
4+
indexList = []
5+
for i in range(N):
6+
indexList.append(input())
7+
Q = int(input())
8+
9+
for i in range(Q):
10+
tmp = input()
11+
cnt = 0
12+
r = re.compile('.(%s).'%tmp)
13+
tmpList = list(filter(r.match, indexList))
14+
print(tmpList)
15+
for j in indexList:
16+
match = re.findall(re.escape(tmp), j)
17+
#print('match',match)
18+
cnt+=len(match)
19+
#print(cnt)
20+

0 commit comments

Comments
 (0)