QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#295568 | #5076. Prof. Pang and Ants | zzuqy# | WA | 0ms | 3792kb | C++14 | 653b | 2023-12-31 13:44:59 | 2023-12-31 13:44:59 |
Judging History
answer
#include <bits/stdc++.h>
#define N 1000009
#define int long long
using namespace std;
int n, m, a[N];
bool ok(int mid) {
int tmp = 0;
for (int i = 1; i <= n; i++) {
tmp += max( mid - 2 * a[i] - 1, 0ll);
if (tmp >= m)
return 1;
}
return 0;
}
void solve() {
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
int l = 0, r = 1000000000000000000, ans = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (ok(mid))
ans = mid, r = mid - 1;
else
l = mid + 1;
}
printf("%lld\n", ans);
}
signed main() {
int t;
scanf("%lld", &t);
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3792kb
input:
3 2 4 1 2 3 10 1 2 3 5 1 1 2 3 4 5
output:
6 9 4
result:
ok 3 number(s): "6 9 4"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3752kb
input:
1 1 100000000000000 1000000000
output:
100002000000001
result:
wrong answer 1st numbers differ - expected: '200000000000000', found: '100002000000001'