标签:input png 输出 panel html clu color opened ble
第1行:点的数量N。(2 <= N <= 10000) 第2 - N + 1行:点的位置。(-10^9 <= P[i] <= 10^9)
输出最小距离之和
5 -1 -3 0 7 9
20
【分析】:注意LL,距离abs
【代码】:
#include <bits/stdc++.h> using namespace std; #define LL long long int main() { LL n,ans=0; LL a[10000+10]; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); for(int i=0;i<n;i++) { ans+=abs(a[i]-a[n/2]); } cout<<ans<<endl; return 0; }
标签:input png 输出 panel html clu color opened ble
原文地址:http://www.cnblogs.com/Roni-i/p/7787051.html