cswork / OA打开练习工作台

RampOA #1

Banking System I (Top Spenders + Scheduled Payments + Merge)

估计困难评测数据准备中,可先阅读题面

考点(AI 标注)迭代器设计模拟/实现单调栈与堆

同类可判练习:银行账本(四关递进)

Implement a simplified version of a banking system. All operations have a timestamp parameter (stringified ms, range 1 to 10⁹, strictly increasing).

Level 1 — Account Creation, Deposit, Transfer

  • create_account(timestamp, account_id) -> bool
  • deposit(timestamp, account_id, amount) -> int | None
  • transfer(timestamp, source_account_id, target_account_id, amount) -> int | None

Level 2 — Top Spenders

  • top_spenders(timestamp, n) -> list[str] — top n accounts by highest outgoing total (transfer source + pay). Format "account_id(total_outgoing)". Tiebreak alphabetically.

Level 3 — Scheduled Payments with 2% Cashback

  • pay(timestamp, account_id, amount) -> str | None — withdraw amount. Provides 2% cashback (rounded down) refunded 24 hours later (86_400_000 ms). Returns "payment{ordinal}". Cashback processes before any other transaction at its refund timestamp.
  • get_payment_status(timestamp, account_id, payment_id) -> str | None — "IN_PROGRESS" or "CASHBACK_RECEIVED".

Level 4 — Account Merging with Balance History

  • merge_accounts(timestamp, account_id_1, account_id_2) -> bool — merge account_id_2 into account_id_1. Pending cashbacks for account 2 still refund to account 1. Queries with old payment_id must still work via account 1.
  • get_balance(timestamp, account_id, time_at) -> int | None — historical balance after operations at time_at.