1 条题解
-
1
需要使用lower_bound函数,只不过要加读入加速
#include <bits/stdc++.h> using namespace std; long long n, q, a[1000005]; int main() { ios::sync_with_stdio(false); // 读入加速 cin.tie(0); cout.tie(0); cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); for (int i = 1; i <= q; i++) { long long x; cin >> x; int p = lower_bound(a + 1, a + n + 1, x) - a; cout << a[p] << endl; } return 0; }
- 1
信息
- ID
- 449
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 18
- 已通过
- 5
- 上传者