Finish the problem
The solution was much simpler than what I expected, I should just accept that some problems is just brute force...
This commit is contained in:
parent
a101940e6a
commit
45e06a9b72
@ -69,11 +69,6 @@ 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);
|
||||||
@ -101,66 +96,40 @@ int main()
|
|||||||
total += cards.back();
|
total += cards.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
V<player> players(p);
|
int amax = 0;
|
||||||
int lim = cards.size() / p;
|
int cmax = 1;
|
||||||
|
bool keep = true;
|
||||||
|
for (cmax = 1; keep; cmax++) {
|
||||||
|
amax = 0;
|
||||||
|
size_t pi = 0;
|
||||||
|
size_t i = 0;
|
||||||
|
int now = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
size_t now = 0;
|
for (; i < cards.size() && pi < p; i++) {
|
||||||
for (size_t i = 0; i < lim * p;) {
|
if (now + cards[i] > cmax) {
|
||||||
for (size_t j = 0; j < lim; j++, i++) {
|
if (now == 0) {
|
||||||
players[now].cards.push_back(cards[i]);
|
pi = p;
|
||||||
players[now].total += cards[i];
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
now++;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (count < cards.size()) {
|
|
||||||
players[now - 1].cards.push_back(cards[count]);
|
|
||||||
players[now - 1].total += cards[count];
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t i = 1;
|
|
||||||
while (i < p) {
|
|
||||||
int act = max(players[i].total, players[i - 1].total);
|
|
||||||
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
rmax(amax, count);
|
||||||
|
now = 0;
|
||||||
|
count = 0;
|
||||||
|
pi++;
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmax = 0;
|
now += cards[i];
|
||||||
for (auto &i : players) {
|
count++;
|
||||||
rmax(cmax, i.total);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int amax = 1;
|
if (i < cards.size()) {
|
||||||
int no = 1;
|
continue;
|
||||||
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);
|
rmax(amax, count);
|
||||||
|
keep = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << amax << ' ' << cmax << '\n';
|
cout << amax << ' ' << cmax - 1 << '\n';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user