Cod sursa(job #1224511)

Utilizator HuehuehueBrazil1HUehuehue Ramstein HuehuehueBrazil1 Data 31 august 2014 11:36:57
Problema Tribute Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
using namespace std;
int dis(int p, int q)
{int s;
    if (p+q<0) s=-p-q;
    else s=p+q;
    return s;
}
int main()
{
    long int n,x,y,i,j,k,v[500],w[500],m=500,e;
    fstream fin("tribute.in");
    fstream fout("tribute.out");
    fin>>n;
    fin>>x;
    fin>>y;
    for (i=1; i<=n; i++) fin>>v[i]>>w[i];

    for (i=1; i<=x; i++)
        for(j=1; j<=y; j++)
            for(k=1; k<=n; k++)
            {
                e=dis(i, v[k])+dis(j, w[k]);
                if (m>=e) m=e;
            }
    fout<<m;
}