Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. /* in the name of Allah */
  2. #include <algorithm>
  3. #include <bitset>
  4. #include <cassert>
  5. #include <cctype>
  6. #include <climits>
  7. #include <cmath>
  8. #include <complex>
  9. #include <cstdio>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <ctime>
  13. #include <deque>
  14. #include <fstream>
  15. #include <functional>
  16. #include <iomanip>
  17. #include <iostream>
  18. #include <limits>
  19. #include <list>
  20. #include <map>
  21. #include <numeric>
  22. #include <queue>
  23. #include <set>
  24. #include <sstream>
  25. #include <stack>
  26. #include <string>
  27. #include <utility>
  28. #include <vector>
  29. using namespace std;
  30.  
  31. typedef long long LL ;
  32. #define ALL(a)              (a).begin(),(a).end()
  33. #define SZ(v)               ((int)(v).size())
  34. #define Clear(x,with)       memset(x , with , sizeof(x))
  35. #define FOR(i,start,end)    for(int i = start ; i < end ; i++)
  36. #define REP(i,start,end)    for(int i = start ; i >= end ; i--)
  37. #define FOREACH(it,x)       for(((x).begin()) it = (x.begin()) ; it != (x).end() ; it++)
  38.            
  39. //set < pair < int , int > s ;
  40.  
  41. class SlimeXSlimesCity
  42. {
  43.     public : int merge(vector <int> p)
  44.         {
  45.             int ans = 0 ;
  46.             int index = 0 ;
  47.             int cnt = 0 ;
  48.            
  49.             sort(ALL(p)) ;
  50.            
  51.             FOR(i,0,SZ(p)){
  52.                 if(cnt + p[i] < p[i + 1] && i + 1 < SZ(p))
  53.                     cnt += p[i] ;
  54.                 else{
  55.                     index = i ;
  56.                     break ;
  57.                 }
  58.             }
  59.            
  60.             ans = SZ(p) - index - 1 ;
  61.            
  62.             return ans ;   
  63.         }
  64. };
  65.  
  66. int main()
  67. {
  68.     SlimeXSlimesCity s ;
  69.     int Array[] = {2, 3, 4} ;//
  70.     //int a[] = {1, 2, 3} ;
  71.     //int a[] = {8,2,3,8} ;
  72.     //int a[] = {1000000000, 999999999, 999999998, 999999997} ;
  73.     //int a[] = {1,1,1} ;
  74.     //int a[] = {1, 2, 4, 6, 14, 16, 20} ;
  75.  
  76.     int size = sizeof(Array) / sizeof(Array[0]);
  77.  
  78.     vector <int> v(Array,Array+size) ;
  79.     cout << s.merge(v) << endl ;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement