| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 18782 | Accepted: 10308 |
Description
Input
Output
Sample Input
2 3 17 41 20 666 12 53 0
Sample Output
1 1 2 3 0 0 1 2
Source
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
//Scanner scan=new Scanner (System.in);
StreamTokenizer st = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
st.nextToken();
int t=(int)st.nval;
for(int i=0;i<t;i++){
st.nextToken();
int n=(int)st.nval;
st.nextToken();
int l=(int)st.nval;
int count=0;
int a[]=new int[n];
for(int j=0;j<n;j++){
st.nextToken();
a[j]=(int)st.nval;
}
Arrays.sort(a);
for(int j=0,k=n-1;j<=k;){
if(a[j]+a[k]<=l){
count++;
j++;k--;
}
else{
count++;
k--;
}
}
if(i!=0)
System.out.println();
System.out.println(count);
}
}
}
POJ 2739 Sum of Consecutive Prime Numbers,布布扣,bubuko.com
POJ 2739 Sum of Consecutive Prime Numbers
原文:http://blog.csdn.net/kimi_r_17/article/details/37909725