-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpiyush_magic_park.cpp
56 lines (55 loc) · 968 Bytes
/
piyush_magic_park.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
51
52
53
54
55
56
#include <iostream>
using namespace std;
int magical_park(char park[][100],int m,int n,int k,int s)
{
bool success=true;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
char ch=park[i][j];
if(s<k)
{
success=false;
break;
}
if(ch=='*')
{
s+=5;
}
else if(ch=='.')
{
s-=2;
}
else{
break;
}
if(j!=n-1)
{
s--;
}
}
}
if(success)
{
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
int main()
{
int m,n,k,s;
cin>>m>>n>>k>>s;
char park[100][100];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>park[i][j];
}
}
magical_park(park,m,n,k,s);
return 0;
}