# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250069 | kaloyan | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10;
int counter[MAXN];
std::pair<std::vector<int>, long long> transaction(long long M);
void buy_souvenirs(int N, long long P0){
if(N == 2)
{
transaction(P0 - 1);
}
else if(N == 3)
{
pair<vector<int>, long long> p = transaction(P0 - 1);
if(p.first.size() == 1)
{
int first_val = (P0 - 1) - R;
transaction(first_val - 1);
transaction(first_val - 1);
}
else
{
int total_sum = (P0 - 1) - R;
transaction(total_sum / 2);
}
}
else
{
for(int i = 0 ; i < N ; ++i)
{
while(counter[i] < i)
{
transaction(N - 1);
counter[i]++;
}
}
}
}