82392024-01-13 19:19:31mmated20G (40 pont)cpp17Accepted 40/4037ms16016 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define f(i,k,n) for(int i=k; i<n; i++)

void solve()
{
    int n,q;
    cin>>n>>q;
    int a[n],b[q];
    f(i,0,n)    cin>>a[i];
    f(i,0,q)    cin>>b[i];
    vector<vector<int>> dp(n);
    dp[0].push_back(a[0]);
    dp[0].push_back(1);
    f(i,1,n)
    {
        dp[i].push_back(max(dp[i-1][0],a[i]));
        dp[i].push_back(i+1);
    }
    sort(dp.begin(),dp.end());
    vector<int> dp2(n);
    f(i,0,n)    dp2[i]=dp[i][0];
    f(i,0,q)
    {
        int asd=upper_bound(dp2.begin(),dp2.end(),b[i])-dp2.begin();
        cout<<dp[asd][1]<<"\n";
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/035ms14528 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2312 KiB
5Accepted2/23ms2576 KiB
6Accepted2/23ms2880 KiB
7Accepted3/34ms3052 KiB
8Accepted3/337ms15172 KiB
9Accepted3/337ms15300 KiB
10Accepted3/337ms15528 KiB
11Accepted4/437ms15484 KiB
12Accepted4/437ms15720 KiB
13Accepted4/437ms15720 KiB
14Accepted4/437ms15908 KiB
15Accepted4/435ms16016 KiB