← 返回 openai 的题目列表GPU Credit Allocation
类型:online_judge
You are managing a GPU service provider, and you need to create a system to manage GPU credit allocations. The system should support querying remaining GPU credits for each user, allocating new GPU credits, and recording usage history. Write functions to implement the following features:
allocate_credit(user_id, credits): Allocate specified GPU credits to a specified user.
check_credit(user_id): Return the remaining GPU credits for a specified user.
usage_history(user_id): Return the usage history of credits for a specified user.
Assume user_id is a string and credits is an integer. Provide at least three use cases to demonstrate how your functions work.
Example
Input
allocate_credit: user_id=user1, credits=100
check_credit: user_id=user1
allocate_credit: user_id=user1, credits=50
usage_history: user_id=user1