# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250438 | discontinuous | 선물 (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
// Author: Anikait Prasar
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
pair<vector<int>, ll> transaction(ll M);
void buy_souvenirs(int n, ll p0) {
if(n==2) {
transaction(p0-1);
return;
}
else if(n==3) {
d = transaction(p0-1).first.size();
c = transaction(p0-1).second;
if(d==1) {
transaction(p0-1-c-1);
}
else {
int sum = p0-1-c;
if(sum&1) {
transaction(sum/2);
}
else {
transaction(sum/2 - 1);
}
}
}
int k = 1;
for(int i = n-1; i>0; i--) {
for(int j = 0; j<k; j++) transaction(i);
k++;
}
}