记录编号 |
574948 |
评测结果 |
AAAAAAAAAA |
题目名称 |
设备分解炉 |
最终得分 |
100 |
用户昵称 |
lihaoze |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2022-08-30 02:15:30 |
内存使用 |
0.00 MiB |
显示代码纯文本
- #include <bits/stdc++.h>
-
- const int N = 10010;
- int n, l, ans;
- int a[N];
-
- bool valid(int t) {
- int x = 0, y = 0;
- for (int j = 1; a[j] < t; ++ j) x = j;
- for (int j = n; a[j] > t; -- j) y = j;
- while (x >= 1 && y <= n)
- if (a[x --] + a[y ++] != 2 * t) return false;
- return true;
- }
-
- int main() {
- freopen("device.in", "r", stdin);
- freopen("device.out", "w", stdout);
- std::cin >> n >> l, l += l;
- for (int i = 1; i <= n; ++ i)
- std::cin >> a[i], a[i] += a[i];
- std::sort(a + 1, a + 1 + n);
- for (int i = 1; i <= l; ++ i)
- ans += valid(i);
- std::cout << ans << '\n';
- return 0;
- }