# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1260595 | robijoy | Souvenirs (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
/*
* Starting with the name of almighty ALLAH
*/
#include "souvenirs.h"
#include <bits/stdc++.h>
using namespace std;
// namespace {
// const int CALLS_CNT_LIMIT = 10000;
// int calls_cnt;
// int N = 3;
// std::vector<long long> P = {11,7,3};
// std::vector<int> Q = {0,0,0};
// void quit(const char* message) {
// printf("%s\n", message);
// exit(0);
// }
// } // namespace
// std::pair<std::vector<int>, long long> transaction(long long M) {
// calls_cnt++;
// if (calls_cnt > CALLS_CNT_LIMIT)
// quit("Too many calls");
// if (M >= P[0] || M < P[N - 1])
// quit("Invalid argument");
// std::vector<int> L;
// long long R = M;
// for (int i = 0; i < N; i++) {
// if (R >= P[i]) {
// R -= P[i];
// Q[i]++;
// L.push_back(i);
// }
// }
// return {L, R};
// }
void buy_souvenirs(int N, long long P0) {
pair<vector<int>,long long> res = transaction(P0-1);
vector<int> robi = res.first;
int ret = res.second;
if(robi.size() == 1) {
int P1 = (P0 - 1) - ret;
transaction(P1-1);
transaction(P1-1);
} else {
transaction((P0-1-ret)/2 - 1);
}
}
// int main() {
// buy_souvenirs(3,11);
// }/*
* Starting with the name of almighty ALLAH
*/
#include "souvenirs.h"
#include <bits/stdc++.h>
using namespace std;
// namespace {
// const int CALLS_CNT_LIMIT = 10000;
// int calls_cnt;
// int N = 3;
// std::vector<long long> P = {11,7,3};
// std::vector<int> Q = {0,0,0};
// void quit(const char* message) {
// printf("%s\n", message);
// exit(0);
// }
// } // namespace
// std::pair<std::vector<int>, long long> transaction(long long M) {
// calls_cnt++;
// if (calls_cnt > CALLS_CNT_LIMIT)
// quit("Too many calls");
// if (M >= P[0] || M < P[N - 1])
// quit("Invalid argument");
// std::vector<int> L;
// long long R = M;
// for (int i = 0; i < N; i++) {
// if (R >= P[i]) {
// R -= P[i];
// Q[i]++;
// L.push_back(i);
// }
// }
// return {L, R};
// }
void buy_souvenirs(int N, long long P0) {
pair<vector<int>,long long> res = transaction(P0-1);
vector<int> robi = res.first;
int ret = res.second;
if(robi.size() == 1) {
int P1 = (P0 - 1) - ret;
transaction(P1-1);
transaction(P1-1);
} else {
transaction((P0-1-ret)/2 - 1);
}
}
// int main() {
// buy_souvenirs(3,11);
// }