Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. //by GB Zaleski
  4. using namespace std;
  5. int Uphold,n;
  6. int tab[30000];
  7.  
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(0);
  11. cin.tie(0);
  12. cout.tie(0);
  13. cin >> Uphold >> n;
  14. for (int i=0; i!=n; ++i) cin >> tab[i];
  15. sort(tab,tab+n);
  16. int x = 0;
  17. int y = n-1;
  18. int result = 0;
  19. while (x <= y)
  20. {
  21. if (tab[x]+tab[y] <= Uphold) ++x;
  22. y--;
  23. result++;
  24. }
  25. cout << result;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement