-
Notifications
You must be signed in to change notification settings - Fork 1
/
hmappy1.cpp
50 lines (50 loc) · 1003 Bytes
/
hmappy1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
void happy(int arr[],char str[],int k,int n,int q)
{
int i,c,l,max,j;
for(i=0;i<=q;i++)
{
c=0,max=0;
if(str[i]=='?')
{
for(j=0;j<n;j++)
{
if(arr[j]==1)
c++;
else if(arr[j]==0)
{
if(c>=max)
max=c;
c=0;
}
if(c>max)
max=c;
}
if(max<=k)
printf("%d\n",max);
else
printf("%d\n",k);
}
else if(str[i]=='!')
{
l=arr[n-1];
for(j=n-1;j>=1;j--)
{
arr[j]=arr[j-1];
}
arr[0]=l;
}
}
}
int main()
{
int n,q,k;
scanf("%d%d%d",&n,&q,&k);
int arr[n],i;
char str[q+1];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
scanf("%s",str);
happy(arr,str,k,n,q);
return 0;
}