Thursday, May 17, 2012
SRM 156 DIV 2 250
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;
public class DiskSpace
{
public int minDrives(int[] used, int[] total)
{
int n= used.length;
int t=0;
ArrayList<Integer> l=new ArrayList();
for(int i=0;i<n;i++)
l.add(total[i]);
Collections.sort(l);
for(int i=0;i<n;i++)
{
t+=used[i];
}
int c=0;
System.out.println(t);
for(int i=0;i<n;i++)
System.out.println("-"+l.get(n-i-1));
for(int i=n-1;i>=0;i--,c++)
{
t-=l.get(i);
if(t<=0)break;
}
return c+1;
}
<%:testing-code%>
}
//Powered by [KawigiEdit] 2.0!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment