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 08fa031 commit af26b0fCopy full SHA for af26b0f
Codeshef/KCON.cpp
@@ -0,0 +1,43 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+int main() {
5
+ int T=0;
6
+ cin>>T;
7
+ while(T--){
8
+ int n=0,k=0;
9
+ long long int cursum=0,sum=0,max=-1000009;
10
+ cin>>n>>k;
11
+ long long int arr[n];
12
+ for(int i=0;i<n;i++){
13
+ cin>>arr[i];
14
+ }
15
+ if(k>100){
16
17
+ sum=sum+arr[i];
18
19
+ for(int i=0;i<2;i++){
20
+ for(int j=0;j<n;j++){
21
+ cursum=cursum+arr[j];
22
+ if(cursum>max)max=cursum;
23
+ if(cursum<0)cursum=0;
24
25
26
+ if(sum>0){
27
+ max=max+(sum*(k-2));
28
29
+ cout<<max<<endl;
30
31
+ else{
32
+ for(int i=0;i<k;i++){
33
34
35
36
37
38
39
40
41
42
+ return 0;
43
+}
0 commit comments