【Codeforces 372A】Counting Kangaroos is Fun
【链接】 我是链接,点我呀:)
【题解】
另外一种错误的思路: 【代码】 import java.io.*; import java.util.*; public class Main { static InputReader in; static PrintWriter out; public static void main(String[] args) throws IOException{ //InputStream ins = new FileInputStream("E:rush.txt"); InputStream ins = System.in; in = new InputReader(ins); out = new PrintWriter(System.out); //code start from here new Task().solve(in,out); out.close(); } static int N = (int)5e5; static class Task{ int n; int s[]; public void solve(InputReader in,PrintWriter out) { s = new int[N+10]; n = in.nextInt(); for (int i = 1;i <= n;i++) { s[i] = in.nextInt(); } Arrays.sort(s,1,n+1); int x = 0; int j = n; for (int i = n/2;i >= 1;i--) { if (s[i]*2<=s[j]){ x++;j--; } } out.println(n-x*2 + x); } } static class InputReader{ public BufferedReader br; public StringTokenizer tokenizer; public InputReader(InputStream ins) { br = new BufferedReader(new InputStreamReader(ins)); tokenizer = null; } public String next(){ while (tokenizer==null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(br.readLine()); }catch(IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |