Submission #19723535


Source Code Expand

Copy
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long[] A = new long[N];
		long[] B = new long[N];
		String[] C = new String[N];
		long Ao = 0;
		long Ta = 0;
		int ans = 0;
		for(int i=0 ; i<N ; i++) {
			A[i] = Long.parseLong(sc.next());
			B[i] = Long.parseLong(sc.next());
			String t = Long.toString(2*A[i]+B[i]);
			int l = t.length();
			t = "000000000000000000000000000000"+t;
			C[i] = t.substring(l-1,(30+l))+'C'+i;
			Ao += A[i];
		}
		Arrays.parallelSort(C,Comparator.reverseOrder());
		int p = 0;
		while(true) {
			int k = Integer.parseInt(C[p].substring(C[p].indexOf('C')+1));
			Ao -= A[k];
			Ta += A[k]+B[k];
			ans++;
			if(Ta>Ao) {
				break;
			}
			p++;
		}
		System.out.println(ans);
	}
}

Submission Info

Submission Time
Task D - Choose Me
User muna
Language Java (OpenJDK 11.0.6)
Score 400
Code Size 922 Byte
Status AC
Exec Time 1319 ms
Memory 83940 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01_small.txt, 02_small.txt, 03_small.txt, 04_small.txt, 05_small.txt, 06_small.txt, 07_small.txt, 08_small.txt, 09_small.txt, 10_small.txt, 11_small.txt, 12_small.txt, 13_small.txt, 14_small.txt, 15_small.txt, 16_large.txt, 17_large.txt, 18_large.txt, 19_large.txt, 20_large.txt, 21_large.txt, 22_large.txt, 23_large.txt, 24_large.txt, 25_large.txt, 26_max.txt, 27_max.txt, 28_max.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01_small.txt AC 160 ms 38924 KB
02_small.txt AC 157 ms 38780 KB
03_small.txt AC 154 ms 38880 KB
04_small.txt AC 160 ms 38876 KB
05_small.txt AC 149 ms 38812 KB
06_small.txt AC 162 ms 38800 KB
07_small.txt AC 156 ms 38772 KB
08_small.txt AC 156 ms 38916 KB
09_small.txt AC 162 ms 38892 KB
10_small.txt AC 159 ms 38964 KB
11_small.txt AC 153 ms 38952 KB
12_small.txt AC 163 ms 38768 KB
13_small.txt AC 156 ms 38748 KB
14_small.txt AC 156 ms 38764 KB
15_small.txt AC 160 ms 38800 KB
16_large.txt AC 873 ms 69188 KB
17_large.txt AC 1319 ms 81700 KB
18_large.txt AC 705 ms 64444 KB
19_large.txt AC 571 ms 65416 KB
20_large.txt AC 752 ms 66704 KB
21_large.txt AC 562 ms 63640 KB
22_large.txt AC 499 ms 63324 KB
23_large.txt AC 227 ms 42116 KB
24_large.txt AC 1108 ms 77940 KB
25_large.txt AC 1226 ms 83408 KB
26_max.txt AC 867 ms 83872 KB
27_max.txt AC 809 ms 83940 KB
28_max.txt AC 854 ms 83132 KB
sample_01.txt AC 160 ms 38776 KB
sample_02.txt AC 158 ms 38884 KB
sample_03.txt AC 164 ms 38940 KB