QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#636019 | #6135. Books | La5te2 | WA | 210ms | 3920kb | C++20 | 733b | 2024-10-12 21:51:16 | 2024-10-12 21:51:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n, m;
ll ans = 0, sum = 0;
cin >> n >> m;
int ok = (n == m);
std::vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
m -= (a[i] == 0);
}
if(ok == 1) return cout << "Richman\n", void();
if(m < 0) return cout << "Impossible\n", void();
int pos;
for(int i = 1; i <= n; i++) {
if(m > 0 && a[i]) ans += a[i], -- m;
if(m == 0) {
pos = i + 1;
break;
}
}
ll minn = 1e18;
for(int i = pos; i <= n; i++) {
if(a[i])minn = min(minn, (ll)a[i] - 1);
}
cout << ans + minn << '\n';
return;
}
int main()
{
int t = 1;
cin >> t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: 210ms
memory: 3920kb
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:
1000000000000000000 0 Impossible 99999999999999 192 80 Richman 1000000000000000000 460 Richman 24 163 1000000000000000000 30 15 Richman Richman Richman 65 Richman Richman 450 98 1000000000000000000 349 1000000000000000000 513 1000000000000000000 161 297 Richman Richman Richman 147 274 10000000000000...
result:
wrong answer 1st lines differ - expected: '1', found: '1000000000000000000'