| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1286478 | kaxi | 선물 (IOI25_souvenirs) | C++20 | 0 ms | 0 KiB |
#include "souvenirs.h"
#include<bits/stdc++.h>
using namespace std;
void buy_souvenirs(int N, long long P0) {
long long curp;
if(N == 2){
pair<vector<int>, long long> res = transaction(P0 - 1);
return;
}
if(N == 3) {
pair<vector<int>, long long> res = transaction(P0 - 1);
if(res.first.size() == 1) {
transaction(P0 - 2 - res.second);
transaction(P0 - 2 - res.second);
}
else {
transaction((P0 - 1 - res.second) / 2);
}
return;
}
if(P0 == N){
for(int i = 1; i < N; i++) {
for(int j = 1; j <= i; j++) {
pair<vector<int>, long long> res = transaction(P0 - i);
}
}
return;
} else {
int cnt1 = 0;
curp = P0 - 1;
for (int i = 1; i <= N; i++0) {
for (int j = 1; j <= i; j++) {
res = trasnaction(curp);
if ((int)res.first.size() > 1) {
cnt++;
curp--;
}
if (res.second > 0) curp--;
}
curp--;
}
for (int i = cnt1 + 1; i <= N - 1; i++) res = transaction(1);
return;
}
}
