Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
TLE help;#include<iostream> #include<algorithm> using namespace std; int x[200000],y[200000],z[200000]; bool cmp(int &z1,int &z2) { return z1>z2; } int main() { int n,i,j,z1,z2,z3; __int64 sum; while(scanf("%d",&n)==1&&n!=0) { sum=0; for(i=0;i<n;i++) { scanf("%d %d %d",&z1,&z2,&z3); x[i]=z1-z2;y[i]=z2-z3;z[i]=z3-z1; } sort(x,x+n,cmp); sort(y,y+n,cmp); sort(z,z+n,cmp); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { sum=sum+((x[i]-x[j])+(y[i]-y[j])+(z[i]-z[j]))/2; } } printf("%I64d\n",sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator