Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. from numba import njit
  2. import numpy as np
  3. import scipy as sp
  4.  
  5.  
  6. class Problem:
  7. def __init__(self, problem):
  8. self.problem = problem
  9. self.output = None
  10. self.B, self.L, self.D, self.S, self.N, self.T, self.M, self.idx = self.read_data()
  11. print(self.B, self.L, self.D)
  12. print(self.S)
  13. print(self.N)
  14. print(self.T)
  15. print(self.M)
  16. print(self.idx)
  17.  
  18. def read_data(self):
  19. filename = f'input/{self.problem}.txt'
  20. lines = [line.strip('\n') for line in open(filename, 'r')]
  21. B, L, D = map(int, lines[0].split())
  22. S = np.array(list(map(int, lines[1].split())))
  23.  
  24. N = np.zeros(L)
  25. T = np.zeros(L)
  26. M = np.zeros(L)
  27. idx = -np.ones(shape=(L, np.max(S)))
  28. for i in range(L):
  29. n, t, m = map(int, lines[2*i + 2].split())
  30. N[i] = n
  31. T[i] = t
  32. M[i] = m
  33. books = np.array(list(map(int, lines[2*i + 3].split())))
  34. books[::-1].sort()
  35. idx[i][:books.shape[0]] = books
  36. return B, L, D, S, N, T, M, idx
  37.  
  38. def run(self):
  39. return None
  40.  
  41. def save(self):
  42. with open(f'output/{self.problem}.out', 'w') as f:
  43. f.write('')
  44. for line in self.output:
  45. f.write(f'{line}\n')
  46.  
  47.  
  48. if __name__ == '__main__':
  49. for problem in ['a']:
  50. cls = Problem(problem)
  51. cls.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement