File tree Expand file tree Collapse file tree 6 files changed +101
-0
lines changed
Expand file tree Collapse file tree 6 files changed +101
-0
lines changed Original file line number Diff line number Diff line change 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 = ' ' )
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments