UVa10474

#include <bits/stdc++.h>
using namespace std;

const int maxn=100005;
int main()
{
    int n,q,x;
    int kase=0;
    int a[maxn];
    while(cin>>n>>q)
    {
        if(n==0 && q==0)
        break;
        cout<<"CASE# "<<++kase<<":"<<endl;
        for(int i=1;i<=n;i++)
            cin>>a[i];
            sort(a+1,a+n+1);
        while(q--)
        {
            cin>>x;
            int t=lower_bound(a+1,a+n+1,x)-a;
            if(a[t]==x)
            cout<<x<<" found at "<<t<<endl;
            else
            cout<<x<<" not found"<<endl;
        }
    }
    return 0;
}

同样的模板,改了几个变量就一直超时,改了一早上也没发现什么问题

原文地址:https://www.cnblogs.com/benzikun/p/10500265.html