Quick modification before having to leave

This commit is contained in:
Segcolt 2024-10-02 12:18:10 -03:00
parent 92daea9371
commit a101940e6a

View File

@ -69,6 +69,11 @@ auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
return is; return is;
} }
struct player {
int total;
list<int> cards;
};
int main() int main()
{ {
ios::sync_with_stdio(false); ios::sync_with_stdio(false);
@ -96,33 +101,65 @@ int main()
total += cards.back(); total += cards.back();
} }
size_t i = 0; V<player> players(p);
size_t j = 0; int lim = cards.size() / p;
int cmax = 0; int count = 0;
int now = 0; size_t now = 0;
while (j < cards.size()) { for (size_t i = 0; i < lim * p;) {
if (total - now < now) { for (size_t j = 0; j < lim; j++, i++) {
now -= cards[i]; players[now].cards.push_back(cards[i]);
i++; players[now].total += cards[i];
continue; count++;
} }
now += cards[j]; now++;
j++;
rmax(cmax, now);
} }
int amax = 0; while (count < cards.size()) {
now = 0; players[now - 1].cards.push_back(cards[count]);
int num = 0; players[now - 1].total += cards[count];
for (auto i : cards) { count++;
if (now + i > cmax) { }
now = i;
num = 1; size_t i = 1;
} else { while (i < p) {
now += i; int act = max(players[i].total, players[i - 1].total);
num++; if (max(players[i - 1].total + players[i].cards.back(), players[i].total - players[i].cards.back()) <= act ||
max(players[i].total + players[i - 1].cards.front(), players[i - 1].total - players[i - 1].cards.front()) < act) {
if (players[i].total + players[i - 1].cards.back() < players[i - 1].total + players[i].cards.front()) {
players[i].total += players[i - 1].cards.back();
players[i - 1].total -= players[i - 1].cards.back();
players[i].cards.push_front(players[i - 1].cards.back());
players[i].cards.pop_back();
} else {
players[i - 1].total += players[i].cards.front();
players[i].total -= players[i].cards.front();
players[i - 1].cards.push_front(players[i].cards.front());
players[i - 1].cards.pop_front();
}
continue;
} }
rmax(amax, num);
i++;
}
int cmax = 0;
for (auto &i : players) {
rmax(cmax, i.total);
}
int amax = 1;
int no = 1;
int val = cards[0];
for (size_t i = 1; i < cards.size(); i++) {
if (val + cards[i] > cmax) {
val = cards[i];
no = 1;
} else {
val += cards[i];
no++;
}
rmax(amax, no);
} }
cout << amax << ' ' << cmax << '\n'; cout << amax << ' ' << cmax << '\n';