Advertisement
Anon2005

Cursuri

Sep 29th, 2022
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3. using namespace std;
  4. ifstream in("cursuri.in");
  5. ofstream out("cursuri.out");
  6. pair <int,int> v[1001];
  7. int t[1001];
  8. int main()
  9. {
  10.     int n,i,p,k,j;
  11.     in>>p>>n>>k;
  12.     for(i=1;i<=n;i++)
  13.         in>>v[i].second>>v[i].first;
  14.     sort(v+1,v+n+1);
  15.     for(i=1;i<=n;i++)
  16.         swap(v[i].first,v[i].second);
  17.     int cnt=0;
  18.     for(i=1;i<=n;i++)
  19.     {
  20.         int max1=0;
  21.         for(j=1;j<=k;j++)
  22.             if(t[j]<=v[i].first&&t[j]>max1)
  23.                 max1=t[j];
  24.         for(j=1;j<=k;j++)
  25.             if(t[j]<=v[i].first&&t[j]==max1)
  26.             {
  27.                 cnt++;
  28.                 t[j]=v[i].second;
  29.                 break;
  30.             }
  31.     }
  32.     if(p==1)
  33.         out<<cnt;
  34.     else
  35.     {
  36.  
  37.     }
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement