diff --git a/hard/day_17/solution.cpp b/hard/day_17/solution.cpp index 8d3ad8d..e8bedc8 100644 --- a/hard/day_17/solution.cpp +++ b/hard/day_17/solution.cpp @@ -1 +1,35 @@ -//write your code here \ No newline at end of file +//write your code here +// Code by Jagpreet153 +#include +using namespace std; +int main(){ + int t; + cin>>t; + while(t--){ + int n,m; + cin>>n>>m; + int a[m],d[m]; + for(int i=0;i>a[i]; + sort(a,a+m); + for(int i=0;i0) ans+=d[m-1-i]; //This is done to simulate the process of protecting the houses. If the resulting distance is greater than zero, it is added to the total number of houses that will be infected in the end + if(d[m-1-i]==0 && j==0) //If the resulting distance is zero and no house has been protected yet (j == 0), one house is protected and added to ans. + { + ans++; + j++; + } + } + cout<