Submission #1311015

#TimeUsernameProblemLanguageResultExecution timeMemory
1311015michael12Souvenirs (IOI25_souvenirs)C++20
0 / 100
1 ms332 KiB
#include "souvenirs.h"
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define sm pair<vector<int>, long long>
using namespace std;
const int inf = 1e9;
int n;
int idx;
int e;
vector<int> dp, cnt;
int slv(ll val){
    auto T = transaction(val);
    vector<int> I = T.ff;
    for(auto tt : I){
        cnt[tt]++;
    }
    ll cst = val - T.ss;
    while(I[0] < e){
        while(e <= I.back()){
            cst -= dp[I.back()];
            I.pop_back();
        }
        e = slv((cst - 1) / I.size());
    }
    dp[I[0]] = cst;
    return I[0];
}
void buy_souvenirs(int N, ll P0){
    n = N;
    e = n;
    dp.resize(n);
    cnt.resize(n);
    slv(P0 - 1);
    for(int i = 0; i < n; i++){
        while(cnt[i] < i){
            transaction(dp[i]);
            cnt[i]++;
        }
    }
    return; 
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...