1 solutions

  • 0
    @ 2025-7-19 19:08:41
    #include<bits/stdc++.h>
    using namespace std;
    const int N=100010;
    int a[N],b[N],k;
    int main()
    {
        int n,m,k;
        cin>>n>>m>>k;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=m;i++) cin>>b[i];
        for(int l=1,r=m;l<=n&&r>=1;)
        {
            if(a[l]+b[r]>k) r--; //当前和大了
            else if(a[l]+b[r]<k) l++; //当前和小了
            else //找到了对应的位置
            {
                cout<<l-1<<" "<<r-1;
                return 0;
            }
        }
        return 0;
    }
    

    Information

    ID
    2881
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    9
    Accepted
    2
    Uploaded By