Skip to content

Instantly share code, notes, and snippets.

@fredbr

fredbr/torre.cpp Secret

Created June 6, 2018 23:20
Show Gist options
  • Save fredbr/55d967bb414af8c7a89258403be9b663 to your computer and use it in GitHub Desktop.
Save fredbr/55d967bb414af8c7a89258403be9b663 to your computer and use it in GitHub Desktop.
//solucao de Carolina Cmvc
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1005
int main()
{
ios_base::sync_with_stdio(false);
int n, m[MAXN][MAXN], l[MAXN], c[MAXN];
cin>>n;
for (int i=0;i<n;i++)
{
int sum=0;
for (int j=0;j<n;j++){
cin>>m[i][j];
sum+=m[i][j];
}
l[i] = sum;
}
for (int j=0;j<n;j++)
{
int sum = 0;
for (int i=0;i<n;i++) sum+=m[i][j];
c[j] = sum;
}
int maior_peso=0;
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++){
m[i][j]=c[j]+l[i]-2*m[i][j];
maior_peso = max(maior_peso, m[i][j]);
}
}
cout<<maior_peso<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment