Guest User

Untitled

a guest
Jan 9th, 2017
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define pb push_back
  4. #define ppb pop_back
  5. #define mp make_pair
  6. #define all(x) (x).begin(),(x).end()
  7. #define sz(x) (int)(x).size()
  8. #define ll long long
  9. #define bit __builtin_popcountll
  10. #define sqr(x) (x) * (x)
  11. #define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
  12. #define debug(x) cout << #x <<" = " << x << endl
  13. #define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
  14. #define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first <<" " << v[i].second << endl;
  15. #define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;
  16.  
  17. using namespace std;
  18.  
  19. typedef pair<int, int> pii;
  20.  
  21. const double eps = 1e-9;
  22. const double pi = acos(-1.0);
  23. const int INF = 1000000000;
  24.  
  25. const int dx[4] = {0, 0, 1, -1};
  26. const int dy[4] = {1, -1, 0, 0};
  27.  
  28. const int N = 101;
  29. int a[N];
  30. int p = 1;
  31. ifstream cin1("lazy_loading.txt");
  32. ofstream cout1("out.txt");
  33. void solve(){
  34. int n;
  35. cin1 >> n;
  36. for(int i = 0; i < n; i++)
  37. cin1 >> a[i];
  38. sort(a, a + n);
  39. reverse(a, a + n);
  40. int l = 0;
  41. int r = n - 1;
  42. int ans = 0;
  43. int w = 0;
  44.  
  45. while(l < r) {
  46. w = 0;
  47. w += a[l];
  48. while(w < 50 && r > l){
  49. r--;
  50. w += a[l];
  51. }
  52. ans++;
  53. l++;
  54. }
  55. cout1 <<"Case #" << p++<<": "<< ans << endl;
  56. }
  57. int main() {
  58. ios_base::sync_with_stdio(0);
  59. int t;
  60. cin1 >> t;
  61. while(t--) solve();
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment