1 条题解
-
1莫言 (slz莫言) LV 10 @ 2024-11-21 20:33:45
#include<bits/stdc++.h> #define int long long using namespace std; const int INF = 0x3f3f3f3f; const int N = 1e5 + 10; int a [N] , n , m; signed main(){ cin >> n; for (int i = 1; i <= n; i++) { scanf ("%d" , &a[i]); } cin >> m; sort(a + 1 , a + 1 + n); int l = 1 , r = n; while(l <= r) { if(a [l] + a [r] == m) { cout << a [l] << " " << a [r]; return 0; } else { if(a[l] + a[r] < m) { l++; } else { r--; } } } cout << "No"; return 0; }
- 1
信息
- ID
- 3112
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- 递交数
- 29
- 已通过
- 7
- 上传者