Submission #1251042

#TimeUsernameProblemLanguageResultExecution timeMemory
1251042wng_Souvenirs (IOI25_souvenirs)C++20
7 / 100
12 ms412 KiB
#include <bits/stdc++.h>
#include "souvenirs.h"

using namespace std;
using ll = long long;

using res_type = pair<vector<int>, ll>;

void buy_souvenirs(int N, ll P0) {
  res_type res;

  if (N == 2) { // s1
    res = transaction(P0 - 1);
    return;
  }

  if (N == 3) { // s4
    res = transaction(P0 - 1);
    bool bought_p2 = res.first[2] > 0;
    ll change = res.second;
    ll used = (P0 - 1) - change;

    if (bought_p2) {
      if (used % 2) {
        transaction(used / 2);
      } else {
        transaction(used / 2 - 1);
      }
    } else { // then (p0 - 1) was not enough?
      ll p1 = used;

      transaction(p1 - 1);
      transaction(p1 - 1);
    }

    return;
  }
  
  if (P0 == N) { // s2
    for (int i = 1; i < N; i++) {
      int price = N - i;
      for (int amt = 1; amt <= i; amt++) {
        transaction(price); 
      }
    }
    return;
  }

  // ll P_i = P0; // good for s3 ??
  // ll to_buy = 0;
  // for (int i = 1; i < N; i++) {
  //   ll bought, change;

  //   for (int amt = i; amt > 0; amt--) {
  //     res = transaction(P_i - 1);
  //     bought = res.first[i];
  //     change = res.second;
  //   }

  //   P_i = (P_i - 1) - change;
  // }

  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...