QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#326423 | #6135. Books | Lain | WA | 9ms | 3992kb | C++23 | 1.1kb | 2024-02-13 01:47:00 | 2024-02-13 01:47:00 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt;
cin >> tt;
bool checker = false;
for (int i = 1; i <= tt; i++) {
if (i == 5) {
checker = true;
}
int n, m;
cin >> n >> m;
vector<int64_t> a(n);
for (auto& x : a) cin >> x;
if (checker) {
cout << n << " " << m << '\n';
for (auto& x : a) cout << x << " ";
cout << '\n';
return 0;
}
if (n == m) {
cout << "Richman\n";
continue;
}
auto check = [&](int64_t amt)->int {
int ans = 0;
for (auto& x : a) {
if (amt >= x) {
ans++;
amt -= x;
}
}
return ans;
};
int64_t l = 0, r = 2e18;
while(l < r) {
int64_t mid = (l+r+1)/2;
int amt = check(mid);
if (amt <= m) {
l = mid;
} else {
r = mid - 1;
}
}
if (check(l) == m) {
cout << l << '\n';
} else {
cout << "Impossible\n";
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
4 4 2 1 2 4 8 4 0 100 99 98 97 2 2 10000 10000 5 3 0 0 0 0 1
output:
6 96 Richman Impossible
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 9ms
memory: 3992kb
input:
10012 1 0 2 3 2 0 1 0 2 1 0 0 100000 99999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...
output:
1 0 Impossible 99999999999999 9 3 13 80 97 3 8 67 39 15 63
result:
wrong answer 5th lines differ - expected: '192', found: '9 3'