Submission #19723978


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	vector<array<int,3>>v;
	int total = 0;
	int s = 0 ;
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		v.push_back({2 * a + b,a,b});
		total += (a + b);
		s += a;
	}
	int have = 0;
	sort(all(v));
	int cnt = 0;
	for(int i = n - 1; i >= 0; i--){
		cnt++;
		
		s -= v[i][0];
		if(s < 0){
			cout << cnt;
			return 0;
		}
	}
	cout << n;
}

Submission Info

Submission Time
Task D - Choose Me
User rohitrj
Language C++ (GCC 9.2.1)
Score 400
Code Size 1148 Byte
Status AC
Exec Time 67 ms
Memory 9476 KB

Compile Error

./Main.cpp: In function ‘int32_t main()’:
./Main.cpp:40:6: warning: unused variable ‘have’ [-Wunused-variable]
   40 |  int have = 0;
      |      ^~~~

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 9 ms 3400 KB
02_small.txt AC 2 ms 3468 KB
03_small.txt AC 2 ms 3456 KB
04_small.txt AC 2 ms 3548 KB
05_small.txt AC 4 ms 3408 KB
06_small.txt AC 3 ms 3540 KB
07_small.txt AC 3 ms 3528 KB
08_small.txt AC 3 ms 3512 KB
09_small.txt AC 2 ms 3460 KB
10_small.txt AC 2 ms 3616 KB
11_small.txt AC 2 ms 3560 KB
12_small.txt AC 2 ms 3520 KB
13_small.txt AC 2 ms 3400 KB
14_small.txt AC 2 ms 3508 KB
15_small.txt AC 5 ms 3508 KB
16_large.txt AC 40 ms 6324 KB
17_large.txt AC 64 ms 9420 KB
18_large.txt AC 21 ms 4716 KB
19_large.txt AC 20 ms 4724 KB
20_large.txt AC 30 ms 4896 KB
21_large.txt AC 19 ms 4792 KB
22_large.txt AC 19 ms 4784 KB
23_large.txt AC 9 ms 3568 KB
24_large.txt AC 55 ms 9476 KB
25_large.txt AC 67 ms 9308 KB
26_max.txt AC 58 ms 9376 KB
27_max.txt AC 52 ms 9472 KB
28_max.txt AC 65 ms 9376 KB
sample_01.txt AC 3 ms 3524 KB
sample_02.txt AC 2 ms 3532 KB
sample_03.txt AC 2 ms 3544 KB