1 条题解

  • 0
    @ 2025-3-16 0:15:31

    屡次贩糖&不会python

    #include <bits/stdc++.h>
    using namespace std;
    
    const int N = 1e5 + 10;
    
    int n, m, a[N];
    map<int, bool> ex;
    
    int main() {
        cin >> n;
        for(int i = 1; i <= n; ++ i) cin >> a[i];
        cin >> m;
    
        sort(a + 1, a + 1 + n);
        for(int i = 1; i <= n; ++ i) ex[a[i]] = 1;
        for(int i = 1; i <= n; ++ i) {
            if(ex[m - a[i]]) {
                cout << a[i] << ' ' << m - a[i] << endl;
                return 0;
            }
        }
        puts("No");
    
        return 0;
    }
    
    n = int(input())
    a = list(map(int, input().split()))
    m = int(input())
    
    flg = 0;
    a.sort()
    ex = []
    for i in a:
        ex.append(i)
    for i in a:
        if m - i in ex: #不会优化TAT
            print(i, m - i, sep = ' ')
            flg = 1
            break
    if not flg:
        print("No")
    
    

    信息

    ID
    373
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    24
    已通过
    6
    上传者