# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1252721 | nickolasarapidis | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include "souvenirs.h"
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
void buy_souvenirs(int N, long long P0){
pair<vector<int>, long long> a;
vector<int> cnt(N, 0);
if(N == 2){
a = transaction(P0 - 1);
return;
}
for(int i = 1; i < N; i++){
if(cnt[i] == i) continue;
a = transaction(P0 - 1);
cnt[i]++;
if(a.S == 1) P0 -= 2;
{ else{
if(a.F.size() == 1){
P0--;
}
else{
cnt[i + 1]++;
P0 -= 2;
}
}
for(int j = cnt[i]; j < i; j++){
a = transaction(P0);
}
}
}