A traffic light at the turn for the “MEGA” shopping center from the Novomoskovskiy highway works in such a way thatkcars are able to take a turn in one minute. At weekends all the residents
of the city drive to the mall to take a shopping, which results in a huge traffic jam at the turn. Administration of the mall ordered to install a camera at the nearby bridge, which is able to calculate the number of cars approaching this turn from the city.
The observation startednminutes ago. You should use the data from the camera to determine the number of cars currently standing in the traffic jam.
Input
The first line contains integerskandn(1 ≤k,n≤ 100), which are the number of cars that can take a turn to “MEGA” in one minute and the number of minutes passed
from the beginning of observation. The second line contains space-separated integersa1, …,an(0
≤ai≤ 100), whereaiis the number of cars that approached the turn during thei-th
minute. The observation started at morning, when there were no cars at the turn.
Output
Output the number of cars currently standing in the traffic jam.
Samples
input
output
5 3
6 7 2
|
0
|
5 3
20 0 0
|
5
|
注意:
1 每分钟只能通过k车了,如果不足k车,那么本分钟内也不会通过超过k车了
#include <iostream>
using namespace std;
void TurnForMEGA()
{
int k = 0, n = 0, a = 0, left = 0;
cin>>k>>n;
for (int i = 0; i < n; i++)
{
cin>>a;
left = a + left - k;
if (left < 0) left = 0;
}
cout<<left<<endl;
}
分享到:
相关推荐
媒体解码.K-Lite.CodecPack.14.2.0.Mega.简体中文多语言免费版,超级强大的音频播放器,K-Lite Codec Pack为您提供绝大多数影音格式的解码器,装了它,您的播放器就可以通吃绝大多数的影音格式。标准版包括了播放...
单片机mega16实验报告——二十四小时倒计时程序.docx单片机mega16实验报告——二十四小时倒计时程序.docx单片机mega16实验报告——二十四小时倒计时程序.docx单片机mega16实验报告——二十四小时倒计时程序.docx...
单片机mega16实验报告——二十四小时倒计时程序.pdf单片机mega16实验报告——二十四小时倒计时程序.pdf单片机mega16实验报告——二十四小时倒计时程序.pdf单片机mega16实验报告——二十四小时倒计时程序.pdf单片机...
elecfans.com-MEGA128系统板PCB电路原理图(1)
LSI阵列卡管理软件,并且使用LSI芯片的其他品牌阵列卡也能用。最新的v17.05.06.00版需要特定jre安装,压缩包内已包含,按照说明直接复制再安装即可。(2023-04-14更新安装说明)
K-Lite_Codec_Pack_1.0.7.1_Mega_JiSuXia这个软件是做高压缩DVD必备软件,可以播放任何硌式视频,也可以剪辑。非常好用。
dd-wrt.v24-44715_NEWD-2_K3.x_mega-brcm5357
Linux MegaRAID device driver for Linux.
windows图形化界面raid分区工具MegaRAID-Storage-Manager
MegaRAID Storage Manager 17.05.00.02_Windows_MSM版本
本程序是用Mega16的串口来控制舵机,采用PWM波来控制舵机。
固件升级
mega16 11.0592mhz 中断方式 接收 发送
mega16_32实验板上的程序:mega16+LCD1602+遥控器输入
Mega128 串口中断方式 端口控制。
AVR MEGA32单片机串口通信程序 仿真软件:protues
基于队列的Mega8 UART通信驱动程序 文件名:uart.c 编译:WinAVR-20070122 硬件:CA-M8X 时钟:外部4MHz
利用mega16自带的AD进行电压测量.测量范围0~5V.
mega16内部EEPROM mega16内部EEPROM