diff --git a/Data Structures and Libraries/Cards Distribution.cpp b/Data Structures and Libraries/Cards Distribution.cpp index f5f8fc2..2bea532 100644 --- a/Data Structures and Libraries/Cards Distribution.cpp +++ b/Data Structures and Libraries/Cards Distribution.cpp @@ -87,7 +87,7 @@ int main() } vi cards; - ll total = 0; + int total = 0; while (n--) { string a; @@ -96,23 +96,10 @@ int main() total += cards.back(); } - size_t i = 0; - size_t j = 0; - int cmax = 0; - int now = 0; - while (j < cards.size()) { - if (total - now < now) { - now -= cards[i]; - i++; - continue; - } - now += cards[j]; - j++; - rmax(cmax, now); - } + int cmax = max(cards[0], total / p); int amax = 0; - now = 0; + int now = 0; int num = 0; for (auto i : cards) { if (now + i > cmax) {