Advertisement
Guest User

Untitled

a guest
May 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. struct pr
  6. {
  7. int x,y;
  8. } v[10005];
  9. bool comp(pr a, pr b)
  10. {
  11. return (a.x>b.x);
  12. }
  13. int n,i,frec[10005],nr,s,maxx,p,j;
  14. ifstream cin("credite.in");
  15. ofstream cout("credite.out");
  16. void citiren()
  17. {
  18. cin>>n;
  19. }
  20. void citire()
  21. {
  22. for(i=1; i<=n; i++){
  23. cin>>v[i].x>>v[i].y;
  24. maxx=max(maxx,v[i].y);
  25. }
  26. sort(v+1,v+n+1,comp);
  27. }
  28. void rezolvare()
  29. {
  30. for(i=1;i<=n;i++)
  31. {
  32. p=-1;
  33. for(j=1;j<=v[i].y;j++)
  34. if(frec[j]==0)
  35. p=j;
  36. frec[p]=v[i].x;
  37. }
  38. for(i=1;i<=maxx;i++)
  39. s=s+frec[i];
  40. }
  41. void printare()
  42. {
  43. cout<<s;
  44. }
  45. int main()
  46. {
  47. citiren();
  48. citire();
  49. rezolvare();
  50. printare();
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement