江湖救急
  • 板块灌水区
  • 楼主Digital_Sunrise
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/26 09:06
  • 上次更新2024/10/26 11:33:47
查看原帖
江湖救急
413301
Digital_Sunrise楼主2024/10/26 09:06

从来没用过lower_bound 今天一用出问题了

#include <bits/stdc++.h>
#define int long long
using namespace std;
 
int a[1000]; 
 
signed main()
{
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> a[i];
	while(1)
	{
		int x;
		cin >> x;
		int p = lower_bound(a + 1,a + n + 1,a[x]) - a;
		cout << p << endl;
	}
	return 0; 
}

此代码为何无法输出正确结果?

2024/10/26 09:06
加载中...