5 条题解

  • 1
    @ 2023-9-9 14:53:47
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int n, m, a[100005];
    int main() {
        freopen("sum.in", "r", stdin);
        freopen("sum.out", "w", stdout);
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr), cout.tie(nullptr); 
        cin >> n;
        for (int i = 0; i < n; cin >> a[i++]);
        cin >> m;
        sort(a, a + n);
        for (int i = 0; i < n && a[i] <= m >> 1; i++)
            if (binary_search(a + i + 1, a + n, m - a[i])) {
                cout << a[i] << ' ' << m - a[i];
                return 0;
            }
        cout << "No";
        return 0;
    }
    

    信息

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