| 1 |
n=int(input()) m=int(input()) count=0 c=[] for i in range(n): a = int(input()) c.append(a) c.sort() for i in range(len(c)-1): s=c[i]+c[i+1] if c[i]==m: coumt=0 break if s<m: count+=1 print(count+1) import math def main(): side, x, y = map(int, raw_input().split()) norm_x = float(x)/side norm_y = float(y)/side if not -side < x < side: # print "b " print "-1" return floored_y = math.floor(norm_y) if floored_y == norm_y: #print "d " print "-1" return else: # Check for floored_y if floored_y % 2 == 1 or floored_y == 0: # Check if x is correct if -0.5 < norm_x < 0.5: if floored_y == 0: square_no = 1 else: square_no = floored_y + math.ceil(floored_y/2) else: #print "e " print "-1" return else: # Even floored_y case # Check if it in positve or negative x if norm_x > 0: # Positive case square_no = 1.5*(floored_y) + 1 elif norm_x < 0: # Negative case square_no = 1.5*(floored_y) else: #print "f " print "-1" return print int(square_no) return if __name__ == "__main__": main() from collections import Counter n, m = map(int, input().split()) def build_graph(): GI = Counter() GO = Counter() l = input().strip() for i, s in enumerate(l): if s == '>': for j in range(m - 1): GO[i * m + j] += 1 GI[i * m + j + 1] += 1 else: for j in range(1, m): GO[i * m + j] += 1 GI[i * m + j - 1] += 1 l = input().strip() for j, s in enumerate(l): if s == 'v': for i in range(n - 1): GO[i * m + j] += 1 GI[(i + 1) * m + j] += 1 else: for i in range(1, n): GO[i * m + j] += 1 GI[(i - 1) * m + j] += 1 return GI, GO if __name__ == "__main__": GI, GO = build_graph() for v, c in GI.items(): if c == 0 or GO[v] == 0: print("NO") exit(0) print("YES") |
Комментарии