1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| def maxTaskCount1(tasks): tasks.sort(key=lambda x : x[1]) count = 0 used = set() for si, ei in tasks: for d in range(si, ei + 1): if d not in used: used.add(d) count += 1 break
return count
def maxTaskCount2(tasks): tasks.sort(key=lambda x : x[1]) count = 0 current_day = 0 for si, ei in tasks: current_day = max(si, current_day + 1)
if current_day <= ei: count += 1
return count
if __name__ == "__main__": m = int(input()) tasks = [] for _ in range(m): tasks.append(list(map(int, input().split()))) print(maxTaskCount1(tasks)) print(maxTaskCount2(tasks))
|