Getting right answer while compilation but unable to pass all the test cases

#include
using namespace std;

int main()
{
int n, m, k, S;
cin >> n;
cin >> m;
cin >> k;
cin >> S;

char a[n][m];
for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
        cin >> a[i][j];
    }
}

for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
        if(a[i][j] == '.'){
            S = S - 3;
        }
        else if(a[i][j] == '*'){
            S = S + 4;
        }
        else if(a[i][j] == '#'){
            break;
        }
        if(j == m-1){
            S = S+1;
        }
    }
    
}
if(S >= k){
    cout << "Yes" << endl << S;
}
else{
    cout << "No" << endl;
}




return 0;

}

@simmy_gupta0404 strength S should be greater than or equal to K at every step of piyush.

okay. got it. Thanks

1 Like