제출 #1359049

#제출 시각아이디문제언어결과실행 시간메모리
1359049avahw선물 (IOI25_souvenirs)C++20
18 / 100
0 ms344 KiB
#include "souvenirs.h"
#include <utility>
#include <vector>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

void buy_souvenirs(int N, long long P0) {
  int n = N;
  vector<ll> p(N, -1);
  p[0] = P0;
  ll p0 = P0;
  vector<int> amount_needed(N);
  for(int i = 0; i < n; i++) amount_needed[i] = i;
  pair<vector<int>, ll> buy = transaction(p0 - 2);
  int a = buy.first[0];
  ll change = buy.second;
  int b = -1;
  if(buy.first.size() == 2) b = buy.first[1];
  // if we brought a singular 1
  if(a == 1 && b == -1){
    p[a] = P0 - 2 - change;
    transaction(p[a] - 1);
    transaction(p[a] - 1);
    return;
  }
  // if we only brought 2
  if(a == 2 && b == -1){
    p[2] = P0 - 2 - change;
    p[1] = p0 - 1;
    transaction(p[1]);
    transaction(p[2]);
    return;
  }
  // if we brought a and b
  // t = p0 + a + b
  ll s = p0 - 2 - change;
  // p0 > a > s / 2
  // 0 < b < s / 2
  // for(auto e : p) cout << e << " ";
  transaction(s / 2);
  

}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…