Skip to content

Instantly share code, notes, and snippets.

@thegreatshasha
Created May 2, 2016 18:42
Show Gist options
  • Save thegreatshasha/77e70178f02c8738cc6e414307b1c15a to your computer and use it in GitHub Desktop.
Save thegreatshasha/77e70178f02c8738cc6e414307b1c15a to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{ long long int r = 1;
while(true)
{
long long int N, num=0, init=0, count=0;
//cin>>N;
scanf("%lld", &N);
if(N==0)
{
break;
}
long long int sum[N];
for(int i=0;i<N;i++)
{
sum[i] = 0;
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
//cin>>num;
scanf("%lld", &num);
sum[i] += num;
sum[j] -= num;
init += num;
}
}
for(int i=0;i<N;i++)
{
//cout<<"inflow:"<<inflow[i]<<" outflow:"<<outflow[i];
if(sum[i]>0)
{
count+=sum[i];
}
}
printf("%lld. %lld %lld\n", r++, init, count);
//cout<<r+1<<"."<<" "<<init<<" "<<count<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment