|
|
back to boardWA #13. Dear Author, please comment long min = n; for (int i = 0; i < k; i++) for (int j = i + 1; j < k; j++) { long diff = (data[i] + data[j] - n); if (diff < min) min = diff; } Console.WriteLine(min < 0 ? 0 : min); Re: WA #13. Dear Author, please comment Sorry, it's my fault. This case find Max, not Min. Re: WA #13. Dear Author, please comment Does you algorithm work (with your last changes)? Re: WA #13. Dear Author, please comment It probably shouldn't (if I am correct) Consider the following 3 3 2 2 2 The answer, program will give you in this case is 1 But i can easily prove it is wrong: First man speaks dialects 1 and 2 Second one speaks dialects 2 and 3 The third speaks dialects 3 and 1 Therefore there is nobody, who can speak all three dialects Re: WA #13. Dear Author, please comment Posted by jim 3 Jul 2018 08:03 you help a lot,thank you |
|
|