Submission #1306569
Source Code Expand
import java.io.*; import java.math.*; import java.util.*; public class Main { private static boolean debug = false; private static boolean elapsed = false; private static PrintWriter _out = new PrintWriter(System.out); private static PrintWriter _err = new PrintWriter(System.err); private void solve(Scanner sc) { int N = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } Arrays.sort(A); int t = 0; long sum = 0; for (int i = 0; i < N - 1; ++i) { if (2 * (sum + A[i]) < A[i + 1]) { t = i + 1; } sum += A[i]; } _out.println((N - t)); } private static BigInteger C(long n, long r) { BigInteger res = BigInteger.ONE; for (long i = n; i > n - r; --i) { res = res.multiply(BigInteger.valueOf(i)); } for (long i = r; i > 1; --i) { res = res.divide(BigInteger.valueOf(i)); } return res; } private static BigInteger P(long n, long r) { BigInteger res = BigInteger.ONE; for (long i = n; i > n - r; --i) { res = res.multiply(BigInteger.valueOf(i)); } return res; } /* * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9 * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18 */ public static void main(String[] args) { long S = System.currentTimeMillis(); Scanner sc = new Scanner(System.in); new Main().solve(sc); _out.flush(); long G = System.currentTimeMillis(); if (elapsed) { _err.println((G - S) + "ms"); } _err.flush(); } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | hhelibex |
Language | Java8 (OpenJDK 1.8.0) |
Score | 400 |
Code Size | 1831 Byte |
Status | AC |
Exec Time | 494 ms |
Memory | 51092 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 479 ms | 48520 KB |
in10.txt | AC | 333 ms | 45932 KB |
in11.txt | AC | 436 ms | 48672 KB |
in12.txt | AC | 452 ms | 48328 KB |
in13.txt | AC | 471 ms | 49800 KB |
in2.txt | AC | 489 ms | 49172 KB |
in3.txt | AC | 487 ms | 46756 KB |
in4.txt | AC | 494 ms | 51092 KB |
in5.txt | AC | 343 ms | 48316 KB |
in6.txt | AC | 444 ms | 47768 KB |
in7.txt | AC | 483 ms | 50396 KB |
in8.txt | AC | 439 ms | 47568 KB |
in9.txt | AC | 233 ms | 35292 KB |
sample1.txt | AC | 92 ms | 19412 KB |
sample2.txt | AC | 93 ms | 20688 KB |
sample3.txt | AC | 92 ms | 23764 KB |