You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// calcula o maior k possível em [1 .. ans] e testa se ele é suficiente, pois prioriza os tickets mais caros nas posições que terão uma taxa de contribuição maior
bool can(int ans) {
ll k = 0; // soma atual
int p = 0; // preço do ingresso atual
if (x < y) swap(x, y), swap(a, b);
for (int i = 1; i <= ans; i++) if (i%a == 0 && i%b == 0) k += prices[p++] * (x+y);
for (int i = 1; i <= ans; i++) if (i%a == 0 && i%b != 0) k += prices[p++] * x;
for (int i = 1; i <= ans; i++) if (i%a != 0 && i%b == 0) k += prices[p++] * y;