#include <utility>
#include <vector>
#include <bits/stdc++.h>
#include "souvenirs.h"
using namespace std;
// std::pair<std::vector<int>, long long> transaction(long long M);
typedef long long ll;
void buy_souvenirs(int N,ll lst)
{
ll P0=lst;
ll cnt[N+2]={0};
for(int i=1;i<N;i++)
{
auto ans=transaction(P0-1);
ll sm=0,tot=0;
for(auto x:ans.first)
{
cnt[x]++;
tot++;
sm-=(x-i);
}
while(cnt[i]<i)
{
ans=transaction(P0-1);
for(auto x:ans.first)
cnt[x]++;
}
// cout<<sm<<' '<<tot<<endl;
ll used=P0-1-ans.second;
ll P1=(used-sm+tot-1)/tot;
P0=P1;
}
// 1 2
// sm = -1
// tot = 2
// (P0-ans.second+1)/2
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |