Advertisement
Singasking

Untitled

Oct 17th, 2022
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct Job {
  4. int startTime;
  5. int endTime;
  6. };
  7. const int N=10e5;
  8. int main() {
  9. int n;
  10. cin>>n;
  11. Job jobs[n];
  12. int time[N]={0};
  13. for(int i=0;i<n;i++) {
  14.  
  15. cin>>jobs[i].startTime>>jobs[i].endTime;
  16. time[jobs[i].startTime]+=1;
  17. time[jobs[i].endTime]-=1;
  18.  
  19. }
  20. int maxConcurrentJobs=time[0];
  21. for(int i=1;i<N;i++) {
  22. time[i]+=time[i-1];
  23. maxConcurrentJobs=max(maxConcurrentJobs,time[i]);
  24. }
  25. cout<<maxConcurrentJobs<<endl;
  26.  
  27.  
  28.  
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement