1 条题解

  • 0
    @ 2026-9-30 13:00:25

    C++ :

    
    #include <cstdio>
    typedef long long ll;
    int main(){
        int N;
        if(scanf("%d",&N)!=1) return 0;
        static int col[100005];
        static ll best[1000005];
        for(int i=0;i<=1000000;i++) best[i]=-1;
        int mx=0;
        for(int i=0;i<N;i++){
            ll b; int c;
            if(scanf("%d %lld",&c,&b)!=2) return 0;
            col[i]=c; if(c>mx) mx=c;
            if(b>best[c]) best[c]=b;
        }
        int m;
        if(scanf("%d",&m)!=1) return 0;
        for(int i=0;i<m;i++){
            int c; if(scanf("%d",&c)!=1) return 0;
            ll r = (c>=0 && c<=1000000) ? best[c] : -1;
            printf(i?" %lld":"%lld", r);
        }
        printf("\n");
        return 0;
    }
    
    
    • 1

    信息

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