求解答:这道题是否使用算法? 如果是,是否是使用二分? 如果是二分,那么二分什么? 如果不是,那么使用什么算法?
实话说我看着数据量貌似不大。。。但是为什么我就 T 了呢?
~由于我是个蒟蒻~,所以请各位dalao帮忙调一下我的代码,玄一关。
#include<bits/stdc++.h>
#define int long long
#define map lis
using namespace std;
int n,m;
int a[200005];
int top;
int b[200005];
int eat[200005];
bool ifeat[200005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)cin>>b[i];
top=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(ifeat[j]==false&&a[i]<=b[j]){
ifeat[j]=true;
eat[j]=i;
}
}
if(top>m)break;
}
for(int i=1;i<=m;i++){
cout<<(eat[i]==0?-1:eat[i])<<endl;
}
return 0;
}