GastonFontenla

Untitled

Jul 3rd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. int s,n;
  10. cin >> s >> n;
  11. vector<pair<int,int> >c;
  12. int w,h;
  13.     for(int i=0;i<n;i++)
  14.     {
  15.         cin >> w;
  16.         cin >> h;
  17.         c.push_back({min(w,h),max(w,h)})
  18.     }
  19.  
  20. sort(c.begin(), c.end());
  21. int aux,p=0;
  22.     for(int i=0;i<c.size();i++)
  23.     {
  24.         aux=c[i].first+c[i].second+1;
  25.         if(aux<=s)
  26.         {
  27.             p++;
  28.             s--;
  29.         }
  30.     }
  31.     cout<<p;
  32.     return 0;
  33. }
Add Comment
Please, Sign In to add comment