I think I am encountering some serious problems here, I have coded the solution in about 5 minutes! But Im getting crazy with this judge, Cant get AC although I have tried all testcases provided here, U can check this code yourself and see what I am saying, whats wrong with my code?!
Code: Select all
// Hartals.cpp : Defines the entry point for the console application.
// UVA 10050
#include <iostream>
#include <string>
using namespace std;
int main()
{
int cases;
cin >> cases; // number of cases
int offs = 0; // number of working days lost
int nDays; // total number if simultion days
int parties; // number of parties
bool* days; // array used for days counted
for (int i = 0; i < cases; i++) {
cin >> nDays;
days = new bool[nDays + 1]; // + 1 to pass off by one
cin >> parties;
for (int j = 0; j < parties; j++) {
int hParam; // hartal parameter
cin >> hParam;
for (int k = 1; k <= nDays; k++) {
if (days[k] && k % hParam == 0 && k % 7 != 0 && k % 7 != 6) { // checks : 1- day is counted before 2- day must be a hartal 3- day is saturday 4- day is sunday
offs++;
days[k] = false; // flags the day as counted
}
}
}
delete days;
cout << offs;
if (i != cases - 1)
cout << endl; // used to skip last newline
offs = 0;
}
return 0;
}