QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635914 | #6135. Books | La5te2 | WA | 229ms | 4000kb | C++20 | 686b | 2024-10-12 21:26:58 | 2024-10-12 21:26:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n, m;
ll ans = -1, sum = 0;
cin >> n >> m;
std::vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
ll L = 0, R = 1e18;
while(L <= R) {
ll mid = L + R >> 1, rec = mid;
int cnt = 0;
for(int i = 1; i <= n; i++) {
if(mid >= a[i]) cnt++, mid -= a[i];
}
if(cnt == m) ans = rec, L = rec + 1;
else R = rec - 1;
}
if(ans < 0) cout << "Impossible\n", void();
else if(ans >= sum) cout << "Richman\n", void();
else cout << ans << '\n';
return;
}
int main()
{
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 229ms
memory: 4000kb
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 Impossible 38 80 Richman 97 460 Richman 24 50 98 30 15 Richman Richman Richman 54 Richman Richman 450 24 44 Impossible 34 Impossible 28 99 238 Richman Richman Richman 48 Impossible 2 160 76 58 91 71 3 Richman 125 32 15 Richman 21 26 Richman 7 Richman Impossible 250 Richman Richman 60 ...
result:
wrong answer 4th lines differ - expected: '99999999999999', found: 'Impossible'