This paper considers channel and power allocation for cognitive radio (CR) networks. We assume that the total available spectrum is divided into several bands, each consisting of a group of channels. A centralized base station, enabled by spectrum sensing, is assumed to have the knowledge of all vacant channels, which will be assigned to various CRs according to their requests. The objective of resource allocation is to maximize the sum data rate of all CRs. Since the activities of primary users may cause heavy traffic in some bands while leaving other bands idle, load balancing is first performed to equalize the traffic. A multilevel subset sum algorithm as well as a simpler greedy algorithm is proposed to achieve excellent load balancing performance. After that, an algorithm incorporated with constant-power water filling is proposed to maximize the sum data rate. Simulation results are presented to illustrate the effectiveness of the proposed algorithms.