Submission #19723983
Source Code Expand
Copy
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif
#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;
int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
/*
5 1 2 2
1 3 2 1
-2*a[i]-b[i]
*/
int main() {
long long n; cin >> n;
long long taka = 0;
vector<pair<long long, long long>> v(n); for (long long i = 0; i <= n - 1; i++) cin >> v[i].ff >> v[i].ss, taka += (v[i].ff + v[i].ss);
sort(v.begin(), v.end(), [&](const pair<long long, long long>& x, const pair<long long, long long>& y) {
return 2 * x.ff + x.ss < 2 * y.ff + y.ss;
});
int i = 0;
while (i < n) {
if (taka - (2 * v[i].ff + v[i].ss) <= 0) break;
taka -= (2 * v[i].ff + v[i].ss);
i++;
}
cout << n - i;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Choose Me |
User |
Ausmosian |
Language |
C++ (Clang 10.0.0) |
Score |
400 |
Code Size |
2766 Byte |
Status |
AC |
Exec Time |
305 ms |
Memory |
5936 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
5 ms |
3172 KB |
02_small.txt |
AC |
2 ms |
2996 KB |
03_small.txt |
AC |
3 ms |
3032 KB |
04_small.txt |
AC |
2 ms |
3120 KB |
05_small.txt |
AC |
2 ms |
3028 KB |
06_small.txt |
AC |
2 ms |
3076 KB |
07_small.txt |
AC |
2 ms |
3084 KB |
08_small.txt |
AC |
2 ms |
3000 KB |
09_small.txt |
AC |
1 ms |
2996 KB |
10_small.txt |
AC |
2 ms |
3004 KB |
11_small.txt |
AC |
2 ms |
3084 KB |
12_small.txt |
AC |
3 ms |
3072 KB |
13_small.txt |
AC |
2 ms |
3132 KB |
14_small.txt |
AC |
2 ms |
3000 KB |
15_small.txt |
AC |
2 ms |
3084 KB |
16_large.txt |
AC |
153 ms |
4004 KB |
17_large.txt |
AC |
281 ms |
5632 KB |
18_large.txt |
AC |
89 ms |
3600 KB |
19_large.txt |
AC |
92 ms |
3492 KB |
20_large.txt |
AC |
103 ms |
3808 KB |
21_large.txt |
AC |
82 ms |
3492 KB |
22_large.txt |
AC |
69 ms |
3284 KB |
23_large.txt |
AC |
10 ms |
3200 KB |
24_large.txt |
AC |
235 ms |
5240 KB |
25_large.txt |
AC |
305 ms |
5796 KB |
26_max.txt |
AC |
188 ms |
5912 KB |
27_max.txt |
AC |
190 ms |
5764 KB |
28_max.txt |
AC |
253 ms |
5936 KB |
sample_01.txt |
AC |
2 ms |
2996 KB |
sample_02.txt |
AC |
3 ms |
3004 KB |
sample_03.txt |
AC |
2 ms |
3032 KB |