# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1260597 | robijoy | 선물 (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,1};
// 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 {
int x = max(1LL,((((P0-1)-ret)/2)));
cout<<x<<endl;
pair<vector<int>,long long> rex = transaction(x);
}
}
// int main() {
// buy_souvenirs(3,11);
// }