Cod sursa(job #3332610)
| Utilizator | Data | 7 ianuarie 2026 22:02:25 | |
|---|---|---|---|
| Problema | Inundatii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
#define nmax 50002
using namespace std;
ifstream cin("inundatii.in");
ofstream cout("inundatii.out");
int n,v[3][nmax];
long long sol;
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
for(int j=0;j<3;j++)
cin>>v[j][i];
for(int i=0;i<3;i++){
int med=v[i][(n+1)/2]-(n+1)/2;
for(int j=1;j<=n;j++)
sol+=abs(med+j-v[i][j]);
}
cout<<sol;
return 0;
}
