Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int s,n;
- cin >> s >> n;
- vector<pair<int,int> >c;
- int w,h;
- for(int i=0;i<n;i++)
- {
- cin >> w;
- cin >> h;
- c.push_back({min(w,h),max(w,h)})
- }
- sort(c.begin(), c.end());
- int aux,p=0;
- for(int i=0;i<c.size();i++)
- {
- aux=c[i].first+c[i].second+1;
- if(aux<=s)
- {
- p++;
- s--;
- }
- }
- cout<<p;
- return 0;
- }
Add Comment
Please, Sign In to add comment