diff --git a/Contests/Div 3 494/Explanations/Intense Heat Explanation.txt b/Contests/Div 3 494/Explanations/Intense Heat Explanation.txt index da183cc3..dbd97150 100644 --- a/Contests/Div 3 494/Explanations/Intense Heat Explanation.txt +++ b/Contests/Div 3 494/Explanations/Intense Heat Explanation.txt @@ -30,4 +30,47 @@ int main() printf("%.12f\n", best); return 0; -} \ No newline at end of file +} + +#### My Changes, +Approach 2: +We can also use sliding window technique to solve this question.We can keep on calculating the size of various subarrays of size k where(k<=n) and finally we select the max from each segment and then compare the various size subarrays and keep on inserting them in a vector. At the end we sort the vector and print the last element. + +My code: +#include +using namespace std; +typedef long long int ll; +#define MAX 1000000007 +#define pb push_back + +int main() +{ ios_base::sync_with_stdio(false); + long double t,i,ans=0,n,j,k,c=0,index,pos,maxsum=0,sum=0; + cin>>n>>k; + vectorv(n); + vectoravg; + for(i=0;i>v[i]; + } + while(k<=n) // segments greater than equal to k consecutive days + { + long double sum=0; + long double temp=0; + for(i=0;i