1 条题解

  • 0
    @ 2024-1-29 16:15:13

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int n, m, a[100010], x, t;
    
    int main() {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) 
            cin >> a[i];
        for (int i = 0; i < m; i++) {
        	cin >> x;
        	t = lower_bound(a + 1, a + 1 + n, x) - a;
        	cout << (a[t] == x ? t : -1) << endl;
    	}
            
        
        return 0;
    }
    
    • 1

    信息

    ID
    532
    时间
    10000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者