标签:
Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
1 #include "cstdio" 2 3 int num[1000005]; 4 int T[1000005]; 5 __int64 sum; 6 void mset(int n) 7 { 8 for (int i=1;i<=n;i++) 9 scanf ("%d",&num[i]); 10 } 11 void px(int x,int y) 12 { 13 if (y-x > 1) 14 { 15 int m = x + (y-x)/2; 16 int p = x,q = m,i = x; 17 px(x,m); 18 px(m,y); 19 while (p < m || q < y) 20 { 21 if (q >= y || (p < m && num[p] <= num[q])) 22 T[i++] = num[p++]; 23 else 24 { 25 T[i++] = num[q++]; 26 sum += m-p; 27 } 28 } 29 for (i=x;i<y;i++) 30 num[i] = T[i]; 31 } 32 } 33 int main() 34 { 35 int n; 36 while (~scanf ("%d",&n)) 37 { 38 sum=0; 39 mset(n); 40 px(1,n+1); 41 for (int i=1;i<=n;i++) 42 printf ("%d ",num[i]); 43 printf ("%I64d\n",sum); 44 } 45 46 return 0; 47 }
暑假集训(2)第六弹 ----- Frosh Week(UVA11858)
标签:
原文地址:http://www.cnblogs.com/huas-zlw/p/5697030.html