Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <fstream>
  2. #include<algorithm>
  3. using namespace std;
  4. ifstream fin("camioane.in");
  5. ofstream fout("camioane.out");
  6. int f[100001];
  7. struct pct
  8. {
  9. long long x;
  10. int y;
  11.  
  12. bool operator<(const pct& s )const
  13. {
  14. if(s.x!=x)
  15. return s.x>x;
  16. else
  17. return s.y>y;
  18. }
  19.  
  20. } v[100001],c[100001];
  21.  
  22. int n,m;
  23. int main()
  24. {
  25. int nr;
  26. fin>>n>>m;
  27. for(int i=1; i<=n; i++)
  28. {
  29. fin>>v[i].x;
  30. v[i].y=i;
  31. }
  32. for(int i=1; i<=m; i++)
  33. {
  34. fin>>c[i].x;
  35. c[i].y=i;
  36. }
  37. sort(v+1,v+n+1);
  38. sort(c+1,c+m+1);
  39. int j=1;
  40. for(int i=1; i<=n; i++)
  41. {
  42. if(v[i].x>=c[j].x)
  43. {
  44. f[v[i].y]=c[j].y;
  45. j++;
  46. }
  47. }
  48. fout<<j-1<<endl;
  49. for(int i=1; i<=n; i++)
  50. fout<<f[i]<<" ";
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement