Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- int max(int a, int b);
- int sum_col(int k, int j);
- int r, c;
- int a[1000][1000];
- int main(){
- ifstream in("input.txt");
- ofstream out("output.txt");
- in >> r >> c;
- for(int i = 0; i < r; i++){
- for (int j = 0; j < c; j++)
- in >> a[i][j];
- }
- int sum;
- int max_sum = 0;
- for(int i = 0; i < r; i++){
- for(int j = 0; j < c; j++){
- int sum = 0;
- for(int k = 0; k <= j; k++){
- int n = 0;
- for(int cont = 0; cont <= i; cont++)
- n += a[cont][k];
- cout << n << endl;
- sum = max(sum + n, 0);
- max_sum = max(max_sum, sum);
- }
- }
- }
- out << max_sum;
- return 0;
- }
- int max(int a, int b){
- return (a > b ? a : b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement