// 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 !!!