Optimal interval scheduling with a resource constraint