# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1249999 | haiphong5g0 | 선물 (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#define task "TEST"
#define task2 "A"
#define pl pair<ll, ll>
#define pf push_front
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b, c) for (int i=a; i<=b; i+=c)
#define FORE(i, a, b, c) for (int i=a; i>=b; i+=c)
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int Mod = 998244353;
const int maxn = 1e6;
const ll Inf = 1e16;
pair<vector<int>, ll> res;
ll P[maxn+1], num[maxn+1];
bool Sub2_3(ll n) {
FOR(i, 1, n-2, 1) {
res = transaction(P[i-1]-2);
for (auto p : res.fi) num[p]++;
if (res.fi[0] != i) P[i] = P[i-1] - 1;
else P[i] = P[i-1] - 2;
}
FOR(i, 1, n-2, 1) FOR(j, num[i], i-1, 1)
transaction(P[i]);
FOR(j, num[n-1], n-2, 1) transaction(P[n-1]-1);
}
// std::pair<std::vector<int>, long long> transaction(long long M)
void buy_souvenirs(int n, long long P0) {
P[0] = P0;
if (N == 2) transaction(P[0]-1);
else if (N == 3) {
res = transcation(P[0]-1);
if (res.fi.size() == 1) {
transaction(P[0]-res.se-2);
transaction(P[0]-res.se-2);
}
else transaction((P[0]-1-res.se)/2);
}
else Sub2_3(n);
}
int main()
{
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; //Sieve();
for (t=1; t--;)
{
//Read(); Solve();
}
}