1. Title Description: Click to open the link
2. Problem solving ideas: After sorting from large to small selection, when Take>sum-take stop.
3. Code:
#define _crt_secure_no_warnings#include<iostream> #include <algorithm> #include <string> #include <sstream> #include <set> #include <vector> #include <stack> #include <map> #include < queue> #include <deque> #include <cstdlib> #include <cstdio> #include <cstring> #include < cmath> #include <ctime> #include <functional>using namespace std; #define ME (s) memset (s,0,sizeof (s)) typedef long Long ll;typedef unsigned int uint;typedef unsigned long long ull;typedef pair <int, int> p;const int n= 100+10;int A[n];int Main () {int N; while (~SCANF ("%d", &n)) {int sum=0; for (int i=0;i<n;i++) {scanf ("%d", &a[i]); Sum+=a[i]; } sort (a,a+n); int cnt=0,take=0; for (int i=n-1;i>=0;i--) {take+=a[i]; cnt++; if (take>sum-take) break; } printf ("%d\n", CNT); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
#111 (Div.2) A. Twins