Submission #19723947


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<int, int>& x, const pair<int, int>& 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 0
Code Size 2742 Byte
Status WA
Exec Time 304 ms
Memory 5904 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 23
WA × 8
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 10 ms 3064 KB
02_small.txt AC 2 ms 3052 KB
03_small.txt AC 2 ms 3112 KB
04_small.txt AC 2 ms 3040 KB
05_small.txt AC 2 ms 3108 KB
06_small.txt AC 2 ms 2960 KB
07_small.txt AC 2 ms 3120 KB
08_small.txt AC 5 ms 2952 KB
09_small.txt AC 2 ms 3104 KB
10_small.txt AC 2 ms 3104 KB
11_small.txt AC 2 ms 3060 KB
12_small.txt AC 1 ms 3012 KB
13_small.txt AC 2 ms 2956 KB
14_small.txt AC 3 ms 3052 KB
15_small.txt AC 2 ms 3084 KB
16_large.txt WA 145 ms 4016 KB
17_large.txt WA 285 ms 5712 KB
18_large.txt WA 92 ms 3600 KB
19_large.txt AC 87 ms 3476 KB
20_large.txt WA 101 ms 3504 KB
21_large.txt WA 85 ms 3540 KB
22_large.txt WA 67 ms 3112 KB
23_large.txt AC 7 ms 2992 KB
24_large.txt WA 242 ms 4904 KB
25_large.txt WA 304 ms 5832 KB
26_max.txt AC 183 ms 5816 KB
27_max.txt AC 189 ms 5848 KB
28_max.txt AC 254 ms 5904 KB
sample_01.txt AC 2 ms 2956 KB
sample_02.txt AC 2 ms 2956 KB
sample_03.txt AC 3 ms 3076 KB