-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS1.cpp
More file actions
53 lines (47 loc) · 816 Bytes
/
S1.cpp
File metadata and controls
53 lines (47 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;
int main()
{
int n,m;
int max=0;
cin>>n;
cin>>m;
int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
if(m==1)
{
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
arr[i][j]=arr[i][0];
if(arr[i][j]>max)
max=arr[i][j];
}
}
}
else {
for(int i=0;i<n;i++){
for(int j=1;j<m;j++){
arr[i][j]=arr[i][j]+arr[i][j-1];
if(arr[i][j]>max)
max=arr[i][j];
}
}
}
cout<<max<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(arr[i][j]==max)
{
cout<<i;
i=n-1;
}
}
}
return 0;
}