题解:AT_abc443_c [ABC443C] Chokutter Addiction
声明
已经在 At 上 AC 了。
题目概述
高桥君从
- 他在工作开始的同时打开 chokutte;
- 如果他打开了 chokutte,同时他所处的时间正好为
A_i ,他会立刻关闭 chokutte。 - 如果高桥君关闭了
100 秒的 chokutte,他会再次打开。
题目中,
其中
思路
根据题意模拟即可。逐步模拟,每一次循环把
注意:先把打开 chokutte 的时间加一,之后再判断当前时间是否为
代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,t=0,flag=1,ans=0,close=0,idx=1,sz[1000005]={0};
cin >> n >> m;
for(int i=1;i<=n;i++)cin >> sz[i];
while(t<m){
t++;
if(flag==1){
ans++;
}else{
close++;
}if(t==sz[idx]){
if(flag==1){
close=0,flag=0;
}idx++;
}
if(close==100)flag=1;
}cout << ans;
return 0;
}