
16 Cal.App.4th 906 (1993)
20 Cal. Rptr.2d 311
THE PEOPLE, Plaintiff and Respondent,
v.
STEVEN ARMENDARIZ, Defendant and Appellant.
Docket No. E010944.
Court of Appeals of California, Fourth District, Division Two.
June 17, 1993.
*908 COUNSEL
Jerome P. Wallingford, under appointment by the Court of Appeal, for Defendant and Appellant.
Daniel E. Lungren, Attorney General, George Williamson, Chief Assistant Attorney General, Gary W. Schons, Assistant Attorney General, John T. Swan and Karl T. Terp, Deputy Attorneys General, for Plaintiff and Respondent.
[Opinion certified for partial publication.[*]]
OPINION
HOLLENHORST, J. 

I.
Defendant Steven Armendariz appeals from the sentence he received after pleading guilty to attempted robbery (Pen. Code, §§ 664/211), attempted murder (Pen. Code, §§ 664/187), and robbery (Pen. Code, § 211). He also admitted three firearm-use enhancements (Pen. Code, § 12022.5) and infliction of great bodily injury on the attempted murder charge (Pen. Code, § 12022.7). The plea bargain contemplated that he would receive either 12 or 13 years in prison.
Defendant was sentenced on August 14, 1991, to 13 years in prison. Although defendant was a minor at the time of the offense, the court did not consider a California Youth Authority commitment. Recognizing the error, the court subsequently ordered an amenability study pursuant to Welfare and Institutions Code section 707.2. After receiving a favorable amenability study, the court rejected the Youth Authority recommendation and resentenced defendant to 13 years in prison on February 28, 1992. However, the court ordered that defendant be housed at the Youth Authority pursuant to Welfare and Institutions Code section 1731.5.


*909 II. FACTS
Luis Souto, the victim of the attempted murder, testified at the preliminary hearing that he and his wife went to a bank in Sun City on January 24, 1991, at 9:45 p.m. to make a deposit at an automated teller machine. After completing his deposit transaction, Mr. Souto turned away from the machine and was accosted by defendant demanding money. Before Mr. Souto could respond, defendant shot him in the chest, an inch from his heart.
Mrs. Souto testified that, after her husband was shot, she gave defendant money from her purse. Defendant then left and she drove her husband to the hospital. Both witnesses positively identified defendant as their attacker.
Defendant presented several alibi witnesses to support his misidentification defense.

III. ISSUES
Defendant contends that the trial court erred (1) in failing to consider the recommendation that he be sentenced to the Youth Authority; (2) in not staying the sentence on count I pursuant to Penal Code section 654; (3) in not striking the gun-use enhancements pursuant to Penal Code section 1385, or not staying them pursuant to In re Culbreth (1976) 17 Cal.3d 330 [130 Cal. Rptr. 719, 551 P.2d 23]; (4) in not staying the great bodily injury enhancement on count II pursuant to Penal Code section 654; and (5) in calculating presentence credits.

IV. ALLEGED FAILURE TO CONSIDER THE YOUTH AUTHORITY RECOMMENDATION
(1) In People v. Jones (1988) 46 Cal.3d 585 [250 Cal. Rptr. 635, 758 P.2d 1165], our Supreme Court reviewed the legislative history of the 1982 amendment to Welfare and Institutions Code section 707.2 and concluded that the Legislature intended "to broaden the court's discretion to impose a prison sentence despite a positive YA recommendation.... [¶] The amended section 707.2 provides that the YA report is to address only the minor's amenability to YA training and treatment, but the court's sentencing decision is to be based on five `primary considerations,' only one of which is amenability." (46 Cal.3d at p. 601.)
The considerations listed in the statute are "[t]he need to protect society, the nature and seriousness of the offense, the interests of justice, the suitability of the minor to the training and treatment offered by the Youth Authority, and the needs of the minor...." (Welf. & Inst. Code, § 707.2.)
*910 "The court may decide to reject the recommendation, but its decision to do so must be explained on the record [citation], and must be based on legitimate factors, such as those listed in section 707.2." (People v. Jones, supra, 46 Cal.3d 585, 602.)
(2a) In this case, the trial court reviewed the amenability report and the other sentencing material, and held defendant to the plea bargain, which contemplated a state prison sentence of 12 or 13 years.[1]
The issue thus presented is whether the existence of a plea bargain is a "legitimate factor" for the rejection of the Youth Authority amenability determination. We hold that it is.
We believe that the decisive consideration is the fact that a Youth Authority commitment would preclude imposition of the agreed upon term of 12 or 13 years. The Youth Authority commitment would normally end at age 25 (Welf. & Inst. Code, § 1771), and could end much sooner (Welf. & Inst. Code, §§ 1765, 1766). The commitment is thus an essentially indeterminate one, and it would not carry out the bargained for terms of the plea agreement.[2]
Penal Code section 1192.5 provides, in relevant part, that "[w]here such plea is accepted by the prosecuting attorney in open court and is approved by the court, the defendant, except as otherwise provided in this section, cannot be sentenced on such plea to a punishment more severe than that specified in the plea and the court may not proceed as to such plea other than as specified in the plea." (Italics added.)
(3) "While no bargain or agreement can divest the court of the sentencing discretion it inherently possesses [citation], a judge who has accepted a *911 plea bargain is bound to impose a sentence within the limits of that bargain. [Citation.] `A plea agreement is, in essence, a contract between the defendant and the prosecutor to which the court consents to be bound.' [Citations.] Should the court consider the plea bargain to be unacceptable, its remedy is to reject it, not to violate it, directly or indirectly. [Citation.] Once the court has accepted the terms of the negotiated plea, `[it] lacks jurisdiction to alter the terms of a plea bargain so that it becomes more favorable to a defendant unless, of course, the parties agree.' [Citation.]" (People v. Ames (1989) 213 Cal. App.3d 1214, 1217 [261 Cal. Rptr. 911].)
(2b) Thus, although defendant argues that the plea agreement cannot override the Youth Authority amenability finding under Welfare and Institutions Code section 707.2, we believe that defendant's consent to the plea bargain has exactly that effect. Defendant cannot gamble that sentencing will be more favorable than the plea bargain,[3] and then move to withdraw the plea or appeal if the outcome is not to his liking.[4]
Plea bargaining is essential to the efficient administration of justice. (People v. West (1970) 3 Cal.3d 595, 604-605 [91 Cal. Rptr. 385, 477 P.2d 409].) Fulfillment of the plea bargain here is therefore in the interests of justice, as that term is used in Welfare and Institutions Code section 707.2. The trial court's adherence to the plea bargain was thus within at least one of the criteria listed in that section.[5]
In addition, two other criteria in that section, suitability of the minor to the training and treatment offered by the Youth Authority and the needs of the minor, were accommodated by the trial court's order that defendant be housed at the Youth Authority pursuant to Welfare and Institutions Code section 1731.5. (People v. Lesnick (1987) 189 Cal. App.3d 637, 645-646 [234 Cal. Rptr. 491].)
We find that the trial court's adherence to the plea bargain agreement for either 12 or 13 years in state prison was a proper exercise of its sentencing discretion, notwithstanding the Youth Authority's amenability finding. (4) "`As the People are held strictly to the terms of the plea *912 bargain, the accused also must be held to his agreement.'" (People v. Ames, supra, 213 Cal. App.3d 1214, 1218.)

V.-VIII.[*]
.... .... .... .... .... .... .... .

IX. DISPOSITION
The judgment is affirmed. The case is remanded and the trial court is directed to correct the abstract of judgment as follows: (1) the enhancements on counts I and III pursuant to Penal Code section 12022.5 should be shown as stayed; (2) the enhancement on count II pursuant to Penal Code section 12022.7 should be shown as stayed; and (3) the credit for time spent in custody should be changed to 596 days instead of 548 days.
Ramirez, P.J., and Timlin, J., concurred.
Appellant's petition for review by the Supreme Court was denied September 22, 1993.
NOTES
[*]   Pursuant to California Rules of Court, rules 976(b) and 976.1, this opinion is certified for publication with the exception of parts V, VI, VII and VIII.
[1]  Since the parties disagree on the meaning of the trial court's statement, we quote it in full: "Again, having reviewed the amenability reports from the Department, from the California Youth Authority, from having reviewed the probation report, having reviewed the more recent probation memorandum, also having recently reviewed the prior transcript of the prior sentence and the prior transcript of the plea, the Court is going to make the following order and sentencing: Mr. Armendariz, it appears to me under the terms of this plea agreement, as I note clearly and the record reflects, that it was anticipated that the sentencing would be a state prison sentence as opposed to a California Youth Authority sentence. That does not however mean that I do not have the discretion to still house you at Youth Authority. But I think in following the terms of the bargained for agreement, I am going to be sentencing you to state prison."
[2]  As the prosecutor argued to the trial court: "This was a plea bargain in which we reduced some of the charges and limited the defendant's liability. In return for that, he received a commitment of no more than 13 years. And to now be considering YA I think as a sentence violates that plea agreement. [¶] ... In fact, we wouldn't receive the benefit of the bargain because you could not sentence the defendant, or you could, but you would not get 12 or 13 years out of the defendant on a youth authority commitment because, in effect, a youth authority commitment is a lid sort of a commitment and it's indeterminate below that."
[3]  Defendant was facing an attempted first degree murder charge carrying a potential penalty of life with possibility of parole. (Pen. Code, §§ 187, 190, 664.) The deliberate and premeditated allegation was withdrawn in the plea agreement, thus reducing the potential penalty on this one count to nine years to life. (Pen. Code, §§ 190, 664.)
[4]  Defendant would have the option of withdrawing his guilty plea as stated in Penal Code section 1192.5. (Cf. People v. Johnson (1974) 10 Cal.3d 868 [112 Cal. Rptr. 556, 519 P.2d 604].) Here defendant filed such a motion, but then withdrew it.
[5]  The state prison sentence also reflected the other two criteria in Welfare and Institutions Code section 707.2, the need to protect society and the nature and seriousness of the offense.
[*]   See footnote, ante, page 906.
