Download uva_cpp_clean/10057/10057-9.cpp from slayone/uva_spoj_raw: direct link, hf CLI and curl.
- Browser
- Download file 674 Bytes
-
https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10057/10057-9.cpp
- Command line
-
hf download hf://datasets/slayone/uva_spoj_raw/uva_cpp_clean/10057/10057-9.cpp
-
curl -L -o 10057-9.cpp https://huggingface.co/datasets/slayone/uva_spoj_raw/resolve/main/uva_cpp_clean/10057/10057-9.cpp
674 Bytes
| using namespace std; | |
| int n, nn, v[MAX_N], ct[MAX_V]; | |
| int main(){ | |
| while(scanf("%d",&n) == 1){ | |
| memset(ct, 0, sizeof ct); | |
| for(int i = 0; i < n; i++) scanf("%d", &v[i]), ct[v[i]]++; | |
| nn = n>>1; | |
| if(n&1){ | |
| nth_element(v, v + nn,v + n); | |
| printf("%d %d 1\n", v[nn], ct[v[nn]]); | |
| } | |
| else{ | |
| nth_element(v,v + nn,v + n); | |
| nth_element(v,v + nn - 1,v + n); | |
| if(v[nn] == v[nn - 1]) printf("%d %d 1\n",v[nn], ct[v[nn]]); | |
| else printf("%d %d %d\n",v[nn - 1],ct[v[nn - 1]]+ct[v[nn]],v[nn] - v[nn - 1] + 1); | |
| } | |
| } | |
| return(0); | |
| } | |