Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numba import njit
- import numpy as np
- import scipy as sp
- class Problem:
- def __init__(self, problem):
- self.problem = problem
- self.output = None
- self.B, self.L, self.D, self.S, self.N, self.T, self.M, self.idx = self.read_data()
- print(self.B, self.L, self.D)
- print(self.S)
- print(self.N)
- print(self.T)
- print(self.M)
- print(self.idx)
- def read_data(self):
- filename = f'input/{self.problem}.txt'
- lines = [line.strip('\n') for line in open(filename, 'r')]
- B, L, D = map(int, lines[0].split())
- S = np.array(list(map(int, lines[1].split())))
- N = np.zeros(L)
- T = np.zeros(L)
- M = np.zeros(L)
- idx = -np.ones(shape=(L, np.max(S)))
- for i in range(L):
- n, t, m = map(int, lines[2*i + 2].split())
- N[i] = n
- T[i] = t
- M[i] = m
- books = np.array(list(map(int, lines[2*i + 3].split())))
- books[::-1].sort()
- idx[i][:books.shape[0]] = books
- return B, L, D, S, N, T, M, idx
- def run(self):
- return None
- def save(self):
- with open(f'output/{self.problem}.out', 'w') as f:
- f.write('')
- for line in self.output:
- f.write(f'{line}\n')
- if __name__ == '__main__':
- for problem in ['a']:
- cls = Problem(problem)
- cls.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement