QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635885 | #6135. Books | La5te2 | WA | 221ms | 3876kb | C++20 | 689b | 2024-10-12 21:18:40 | 2024-10-12 21:18:40 |
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 = 2 * sum;
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: 3488kb
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: 221ms
memory: 3876kb
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 192 80 Richman 97 Impossible Richman 24 90 98 30 15 Richman Richman Richman 65 Richman Richman Impossible 24 44 Impossible 34 Impossible 28 99 Impossible Richman Richman Richman 104 Impossible 2 160 76 58 91 Impossible 3 Richman 125 32 15 Richman 21 26 Richman 7 Richman Imp...
result:
wrong answer 4th lines differ - expected: '99999999999999', found: 'Impossible'