Skip to content
Programming101
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

HackerEarth Noor and his pond problem solution

YASH PAL, 31 July 2024
In this HackerEarth Noor and his pond problem solution Noor is going fish farming. There are N types of fish. Each type of fish has size(S) and eating factor(E). A fish with eating factor of E, will eat all the fish of size .
Help Noor to select a set of fish such that the size of the set is maximized as well as they do not eat each other.
HackerEarth Noor and his pond problem solution

HackerEarth Noor and his pond problem solution.

#include <bits/stdc++.h>
using namespace std;

string toZero(int n)
{
string ret;
for(int i = 0; i < 2;i ++) ret.push_back(n%10 + '0'), n/=10;
reverse(ret.begin(), ret.end());
return ret;
}

int main()
{
int t;
cin >>t;
assert(t >= 1 && t <= 3);
while(t--){
int n;
cin >> n;
assert(n >= 1 && n <= 100000);

vector< pair<int,int> > vec;
for(int i = 0; i < n; i ++ ){
int s,e;
cin >> s >> e;
assert(s >= 1 && s <= 1000000000);
assert(e >= 1 && e <= 1000000000);
assert(s > e);
vec.push_back( make_pair(e,1));
vec.push_back( make_pair(s,-1));
}
sort(vec.begin(), vec.end());
int ans = 0, cum = 0;
for(int i = 0; i < vec.size(); i ++){
cum += vec[i].second;
ans = max(ans , cum);
}
cout << ans << endl;
}
}

//}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes