We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6caa4f commit 3e51b31Copy full SHA for 3e51b31
42_codechef_the_great_run.cpp
@@ -0,0 +1,43 @@
1
+//
2
+// main.cpp
3
+// CODE-CHEF
4
5
+// Created by Prince Kumar on 17/05/19.
6
+// Copyright © 2019 Prince Kumar. All rights reserved.
7
8
+// ------ ** The Great Run ** ---------- //
9
+
10
+#include <iostream>
11
+using namespace std;
12
+int main()
13
+{
14
+ int T; cin>>T;
15
+ while(T--){
16
17
+ int n,k; cin>>n>>k;
18
+ int a[n]; // no. of girls per km
19
+ for(int i=0;i<n;i++)
20
+ {
21
+ cin>>a[i];
22
+ }
23
+ // we get values of girls
24
25
+ int max=0;
26
+ for(int i=0;i<=n-k;i++)
27
28
+ int sum=0;
29
+ for(int j=i;j<i+k;j++)
30
31
+ sum+=a[j];
32
33
+ if(max<sum)
34
+ max=sum;
35
36
+ cout<<max<<endl;
37
38
39
+}
40
41
42
43
0 commit comments