Submission #19134915


Source Code Expand

#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

struct P{
	ll a, b;
}p[200010];
int n;
ll now, las;

bool cmp(P x, P y){
	return x.a + 2 * x.b > y.a + 2 * y.b;
}

int main(){

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> p[i].b >> p[i].a;
	sort(p + 1, p + n + 1, cmp);
	for(int i = 1; i <= n; i++)
		las += p[i].b;
	if(now > las){
		puts("0");
		return 0;
	}
	for(int i = 1; i <= n; i++){
		now += p[i].b + p[i].a, las -= p[i].b;
		if(now > las){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Submission Info

Submission Time
Task D - Choose Me
User HoshizoraZ
Language C++ (GCC 9.2.1)
Score 400
Code Size 599 Byte
Status AC
Exec Time 130 ms
Memory 6612 KiB

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 7 ms 3596 KiB
02_small.txt AC 2 ms 3568 KiB
03_small.txt AC 3 ms 3528 KiB
04_small.txt AC 2 ms 3596 KiB
05_small.txt AC 3 ms 3596 KiB
06_small.txt AC 2 ms 3624 KiB
07_small.txt AC 2 ms 3564 KiB
08_small.txt AC 2 ms 3628 KiB
09_small.txt AC 3 ms 3584 KiB
10_small.txt AC 2 ms 3564 KiB
11_small.txt AC 2 ms 3592 KiB
12_small.txt AC 2 ms 3588 KiB
13_small.txt AC 3 ms 3596 KiB
14_small.txt AC 2 ms 3568 KiB
15_small.txt AC 2 ms 3588 KiB
16_large.txt AC 66 ms 4876 KiB
17_large.txt AC 120 ms 6232 KiB
18_large.txt AC 45 ms 4332 KiB
19_large.txt AC 45 ms 4392 KiB
20_large.txt AC 50 ms 4552 KiB
21_large.txt AC 44 ms 4252 KiB
22_large.txt AC 34 ms 4176 KiB
23_large.txt AC 5 ms 3612 KiB
24_large.txt AC 110 ms 5980 KiB
25_large.txt AC 130 ms 6612 KiB
26_max.txt AC 97 ms 6568 KiB
27_max.txt AC 96 ms 6532 KiB
28_max.txt AC 127 ms 6516 KiB
sample_01.txt AC 2 ms 3524 KiB
sample_02.txt AC 2 ms 3568 KiB
sample_03.txt AC 3 ms 3444 KiB