标签:public
http://hihocoder.com/contest/hiho39/problems
java.util.*; Main { = ; mergSort(List<Long> a, l, r) { mid; (l < r) { mid = (l + r) / ; (a,l, mid); (a, mid + , r); List<Long> b1,b2; b1 = ArrayList<Long>(a.subList(l,mid+)); b2 = ArrayList<Long>(a.subList(mid+,r+)); List<Long>a1 = a.subList(l,r+); i1=,i2=,n1=b1.size(),n2=b2.size(),i=; (;i1<n1&&i2<n2;){ ( b1.get(i1)<= b2.get(i2)){ a1.set(i,b1.get(i1)); i1++; i++; } { a1.set(i,b2.get(i2)); i++; +=n1-i1; i2++; } } ( i1< n1){ a1.set(i,b1.get(i1)); i++; i1++; } ( i2< n2){ a1.set(i,b2.get(i2)); i++; i2++; } } } main(String[] args) { List<Long> a; Scanner scanner = Scanner(System.); a= ArrayList(); n1 = scanner.nextInt(); (i = ; i < n1; i++) { a.add(scanner.nextLong()); } (a, , n1 - ); System..println(); } }
本文出自 “8691404” 博客,请务必保留此出处http://8701404.blog.51cto.com/8691404/1627673
标签:public
原文地址:http://8701404.blog.51cto.com/8691404/1627673