Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* in the name of Allah */
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cctype>
- #include <climits>
- #include <cmath>
- #include <complex>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <deque>
- #include <fstream>
- #include <functional>
- #include <iomanip>
- #include <iostream>
- #include <limits>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- using namespace std;
- typedef long long LL ;
- #define ALL(a) (a).begin(),(a).end()
- #define SZ(v) ((int)(v).size())
- #define Clear(x,with) memset(x , with , sizeof(x))
- #define FOR(i,start,end) for(int i = start ; i < end ; i++)
- #define REP(i,start,end) for(int i = start ; i >= end ; i--)
- #define FOREACH(it,x) for(((x).begin()) it = (x.begin()) ; it != (x).end() ; it++)
- //set < pair < int , int > s ;
- class SlimeXSlimesCity
- {
- public : int merge(vector <int> p)
- {
- int ans = 0 ;
- int index = 0 ;
- int cnt = 0 ;
- sort(ALL(p)) ;
- FOR(i,0,SZ(p)){
- if(cnt + p[i] < p[i + 1] && i + 1 < SZ(p))
- cnt += p[i] ;
- else{
- index = i ;
- break ;
- }
- }
- ans = SZ(p) - index - 1 ;
- return ans ;
- }
- };
- int main()
- {
- SlimeXSlimesCity s ;
- int Array[] = {2, 3, 4} ;//
- //int a[] = {1, 2, 3} ;
- //int a[] = {8,2,3,8} ;
- //int a[] = {1000000000, 999999999, 999999998, 999999997} ;
- //int a[] = {1,1,1} ;
- //int a[] = {1, 2, 4, 6, 14, 16, 20} ;
- int size = sizeof(Array) / sizeof(Array[0]);
- vector <int> v(Array,Array+size) ;
- cout << s.merge(v) << endl ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement