Download uva_cpp_clean/10041/10041-9.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 486 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10041/10041-9.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10041/10041-9.cpp
-
curl -L -o 10041-9.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10041/10041-9.cpp
486 Bytes
| using namespace std; | |
| int tc, n, _min, tmp; | |
| vector <int> v; | |
| int main(){ | |
| scanf("%d", &tc); | |
| while(tc--){ | |
| scanf("%d", &n); | |
| v.resize(n); _min = INT_MAX; | |
| for(int i = 0; i < n; i++) | |
| scanf("%d", &v[i]); | |
| for(int i = 0; i < n; i++){ | |
| tmp = 0; | |
| for(int j = 0; j < n; j++) | |
| tmp += abs(v[i] - v[j]); | |
| if(tmp < _min) | |
| _min = tmp; | |
| } | |
| printf("%d\n", _min); | |
| } | |
| return(0); | |
| } | |