package org.acm.greed;
/*http://acm.nyist.net/JudgeOnline/problem.php?pid=6*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedList;
public class NYOJ_6 {
private static int n;
private static String data[];
private static LinkedList<Double> radius = new LinkedList<Double>();
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while (t-- > 0) {
radius.clear();
n = Integer.parseInt(br.readLine());
data = br.readLine().split(" ");
// 将所有装置的半径放入队里,进行排序
for (int i = 0; i < data.length; i++)
radius.add(Double.parseDouble(data[i]));
Collections.sort(radius);
double length = 0;
n = 0;// 计数
// 题目要求是覆盖全部草坪的全部面积,所以别忘了角落
for (int i = radius.size() - 1; i >= 0; i--) {
length += Math.sqrt(radius.get(i) * radius.get(i) - 1) * 2;
n++;
if (length >= 20) {
System.out.println(n);
break;
}
}
}
}
}
NYOJ---6(贪心)-题目---------------------------------喷水装置(一)
最新推荐文章于 2018-08-27 11:15:04 发布