A high tuition fee

Source: Internet
Author: User
// Http://main.edu.pl/en/archive/oi/20/tak
# Include <iostream> # include <algorithm> # include <cstdio> using namespace STD; typedef long ll; # define rep (I, n) for (ll I = 1, N __= N; I <= n __; I ++) # define repb (I, B, n) for (ll I = B, n __= N; I <= n __; I ++) ll D, m, n; const ll Mn = 1000000 + 10; ll a [Mn]; int main () {// freopen ("tak9a. in "," r ", stdin); // freopen (" 9A. out "," W ", stdout); CIN> D> m> N; // cout <D <''<m <'' <n <Endl; rep (I, n) CIN> A [I]; sort (a + 1, A + 1 + n); bool ca N = true; ll ans = 0; ll Ren =-m; if (a [n] <D-m) {can = false; goto ianss; // The first is here, since I have converted "can" into "false", I will output 0 in the end... However, if Im has no initial value re, it crashes} // ll im; rep (I, n) if (a [I]> = D-m) {im = I; break;} ll I; for (I = N; I> = 1; I --) {// cout <"I =" <I <"\ 'Ren =" <Ren <Endl; if (I = IM) {If (Ren * 2> = (D-m)-A [im]) {ans = n-I + 1; break;} continue ;} if (A [I] + Ren> = 0) // This is the second if, because I wrote this during the first write, I always thought there was no problem in my mind, so I didn't care about Ren = Ren * 2 + A [I]; if (I> IM) {If (REN> = D-m) {ans = n-I + 1; break;} else if (Ren * 2> = (D-m) -A [im]) {ans = n-I + 1; break;} If (REN> = 0) Ren = 0 ;} // cout <n <''<I <Endl; // For (ll j = N; j> = I; j --) // cout <A [J] <Endl; ianss: If (CAN & Ans> 0) cout <ans <Endl; else cout <0 <Endl; // cout <n <Endl; // For (INT I = 1; I <= N; I ++) // cout <A [I] <Endl; return 0 ;}

These two errors all have one thing in common: although the results have been fixed, they do not think there will be any problems in the future. Therefore, no special sentence is written, no matter whether it is left blank, leading to a serious error.

1. Write a special sentence for any uncertain circumstances. Then, the Code may become ugly, but the readability and accuracy are improved.

Fight !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.