Round #169 (Div. 2)A、Police Recruits

1、Ad-hoc problem。。。具体不用我说,看代码吧(我真是越来越懒了。。。)
#include<cstdio>
using namespace std;
int a[100010];
int main(){
	int n,num=0,ans=0,temp;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&temp);
        if(temp!=-1) num+=temp;
		else{
			if(num>0) num--;
			else ans++;
		}
	}
	printf("%d\n",ans);
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.6+ based on standard Python type hints. It provides an easy-to-use interface for creating RESTful APIs with minimal boilerplate code. To create a RESTful API for a Schedule, you would typically define the following endpoints: 1. Add: HTTP POST request to add a new schedule item. 2. Delete: HTTP DELETE request to delete an existing schedule item. 3. Select: HTTP GET request to retrieve a list of all schedule items or a single schedule item by ID. 4. Update: HTTP PUT request to update an existing schedule item. Here is an example implementation of these endpoints using FastAPI: ```python from typing import List from fastapi import FastAPI app = FastAPI() class Schedule: def __init__(self, id: int, title: str, description: str, date: str): self.id = id self.title = title self.description = description self.date = date # Mock data schedule_items = [ Schedule(1, "Meeting", "Weekly team meeting", "2022-01-05T10:00:00"), Schedule(2, "Lunch", "Lunch with clients", "2022-01-06T12:30:00"), Schedule(3, "Conference", "Python conference", "2022-01-10T09:00:00"), ] @app.post("/schedule") def add_schedule_item(schedule: Schedule): """ Add a new schedule item. """ schedule_items.append(schedule) return {"message": "Schedule item added successfully."} @app.delete("/schedule/{schedule_id}") def delete_schedule_item(schedule_id: int): """ Delete an existing schedule item by ID. """ for i, schedule in enumerate(schedule_items): if schedule.id == schedule_id: del schedule_items[i] return {"message": "Schedule item deleted successfully."} return {"error": "Schedule item not found."} @app.get("/schedule") def get_all_schedule_items() -> List[Schedule]: """ Retrieve a list of all schedule items. """ return schedule_items @app.get("/schedule/{schedule_id}") def get_schedule_item(schedule_id: int) -> Schedule: """ Retrieve a single schedule item by ID. """ for schedule in schedule_items: if schedule.id == schedule_id: return schedule return {"error": "Schedule item not found."} @app.put("/schedule/{schedule_id}") def update_schedule_item(schedule_id: int, schedule: Schedule): """ Update an existing schedule item by ID. """ for i, s in enumerate(schedule_items): if s.id == schedule_id: schedule_items[i] = schedule return {"message": "Schedule item updated successfully."} return {"error": "Schedule item not found."} ``` With this implementation, you can use HTTP requests to add, delete, select, and update schedule items via the API. For example, to add a new schedule item, you could send a POST request to http://localhost:8000/schedule with a JSON payload containing the schedule data: ```json { "id": 4, "title": "Training", "description": "Training session for new recruits", "date": "2022-01-15T14:00:00" } ``` You could then use GET requests to retrieve the list of all schedule items or a single schedule item by ID, and PUT and DELETE requests to update or delete existing schedule items.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值