Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include<algorithm>
- using namespace std;
- ifstream fin("camioane.in");
- ofstream fout("camioane.out");
- int f[100001];
- struct pct
- {
- long long x;
- int y;
- bool operator<(const pct& s )const
- {
- if(s.x!=x)
- return s.x>x;
- else
- return s.y>y;
- }
- } v[100001],c[100001];
- int n,m;
- int main()
- {
- int nr;
- fin>>n>>m;
- for(int i=1; i<=n; i++)
- {
- fin>>v[i].x;
- v[i].y=i;
- }
- for(int i=1; i<=m; i++)
- {
- fin>>c[i].x;
- c[i].y=i;
- }
- sort(v+1,v+n+1);
- sort(c+1,c+m+1);
- int j=1;
- for(int i=1; i<=n; i++)
- {
- if(v[i].x>=c[j].x)
- {
- f[v[i].y]=c[j].y;
- j++;
- }
- }
- fout<<j-1<<endl;
- for(int i=1; i<=n; i++)
- fout<<f[i]<<" ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement