← 返回 stripe 的题目列表Chat Billing (Compute Chat Usage Charges from Event Logs)
类型:online_judge
Chat Billing (Compute Charges from Chat Event Logs)
You are given a list of events related to “chat session billing”. Compute the final amount to charge according to the billing rules.
Input
The input is a list of events ordered by time (if not guaranteed, sort by timestamp first).
Each event contains at least:
timestamp: event time (integer seconds or milliseconds, per the prompt)
chat_id: unique id of the conversation/session
type: event type (e.g., start/end, message sent, agent join/leave, billing start/stop, etc.; per the prompt)
plus type-specific fields (e.g., message count, participant role, etc.)
Note: The original post does not include the full statement or schema. Please follow the exact OA prompt for event types and fields.
Billing Rules
Using the billing rules provided in the prompt (for example:
bill by agent online duration; or
bill by session duration; or
bill by number of messages/characters; or
bill by active time within certain windows; possibly including free tiers, minimum increments, rounding rules, etc.), compute the fee for each chat_id and aggregate to produce the final charge.
Output
Output the total fee (or an itemized fee by chat_id, per the prompt).
If currency/precision is involved, follow the prompt strictly (e.g., output integer cents).
Constraints
Number of events N: not provided (OA often uses sizes around 1e4).
Example
Not provided in the original post. Use the examples from the OA prompt.