A reinsurance treaty involves two parties, an insurer and a reinsurer. The two parties have conflicting interests. Most existing optimal reinsurance treaties only consider the interest of one party. In this article, we consider the interests of both insurers and reinsurers and study the joint survival and profitable probabilities of insurers and reinsurers. We design the optimal reinsurance contracts that maximize the joint survival probability and the joint profitable probability. We first establish sufficient and necessary conditions for the existence of the optimal reinsurance retentions for the quota-share reinsurance and the stop-loss reinsurance under expected value reinsurance premium principle. We then derive sufficient conditions for the existence of the optimal reinsurance treaties in a wide class of reinsurance policies and under a general reinsurance premium principle. These conditions enable one to design optimal reinsurance contracts in different forms and under different premium principles. As applications, we design an optimal reinsurance contract in the form of a quota-share reinsurance under the variance principle and an optimal reinsurance treaty in the form of a limited stop-loss reinsurance under the expected value principle.