Cod sursa(job #1814022)
Utilizator | Mihai Ueban misu97 | Data | 23 noiembrie 2016 16:38:54 |
---|---|---|---|
Problema | Inundatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
int v,w,vw;
long long rez;
struct cl{
int x,y,z;
} A[100000];
int main(){
ifstream cin("inundatii.in");
ofstream cout("inundatii.out");
int N;
cin>>N;
for(int i=1;i<=N;i++){
cin>>A[i].x>>A[i].y>>A[i].z;
v=A[(N+1)/2].x-N/2;
w=A[(N+1)/2].y-N/2;
vw=A[(N+1)/2].z-N/2;
}
for(int i=1;i<=N;i++){
rez+=1ll*abs(A[i].x-v)+1ll*abs(A[i].y-w)+1ll*abs(A[i].z-vw);
v++,w++,vw++;
}
cout<<rez;
return 0;
}