2 条题解

  • 0
    @ 2025-9-22 21:47:11
    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        map<int, int> mp;  // key: 元素值,value: 排名
        int n, tmp, m;
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> tmp;
            mp.emplace(tmp, 0);
        }
    
        int cnt = 1;
        for (auto &pair : mp) {
            pair.second = cnt++;
        }
    
        cin >> m;
        for (int i = 0; i < m; ++i) {
            cin >> tmp;
            if (mp.find(tmp) != mp.end()) {
                cout << mp[tmp] << '\n';
            } else {
                cout << "No\n";
            }
        }
        return 0;
    }
    
    

    信息

    ID
    405
    时间
    3000ms
    内存
    128MiB
    难度
    10
    标签
    (无)
    递交数
    4
    已通过
    3
    上传者