My issue
Why am I getting "wrong answer"?
My code
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int N;
cin >> N;
int A[N], total_sat_sun=0, total_holiday=0;
for(int i=1; i <= N; i++)
{
cin >> A[i];
}
for(int i =1; i<=30; i++) // counting total saturday & sunday
{
if(i%7 == 0 || i%7 == 6) // checking if it's sunday
{
total_sat_sun++;
}
}
sort(A, A+N); //sorting the festival days
total_holiday+=total_sat_sun; //Sundays and Saturdays are also holidays
for(int j=1; j<=N; j++)
{
if(A[j]%7 != 0 && A[j]%7 != 6) //checking if the festival day is saturday/sunday
{
total_holiday++;
}
}
cout<<total_holiday<<endl;
}
return 0;
}
Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone