Untitled
unknown
python
2 years ago
898 B
3
Indexable
Never
N = input().split(',', 2) n = int(N[0]) m = int(N[1]) t = [0]*m for i in range(m): t[i] = input().split(',', n) for j in range(n): t[i][j] = int(t[i][j]) ans = [0]*n used = [0]*n lastFinish = [0]*m Idle = 0 for _ in range(n): miIdleIdx = 0 miIdle = 1e9 for i in range(n): if used[i]: continue curT = 0 idle = 0 for j in range(m): curT = max(curT, lastFinish[j]) idle += curT-lastFinish[j] curT += t[j][i] if idle < miIdle: miIdle = idle miIdleIdx = i curT = 0 for j in range(m): curT = max(curT, lastFinish[j]) Idle += curT-lastFinish[j] curT += t[j][miIdleIdx] lastFinish[j] = curT ans[miIdleIdx] = max(ans[miIdleIdx], curT) used[miIdleIdx] = True for i in ans: print(i, end=',') print(Idle)