QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#636027 | #6135. Books | La5te2 | WA | 208ms | 4200kb | C++20 | 766b | 2024-10-12 21:53:26 | 2024-10-12 21:53:27 |
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);
}
if(pos > n) minn = a[pos] - 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: 1ms
memory: 3564kb
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: 208ms
memory: 4200kb
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 192 80 Richman -1 460 Richman 24 163 -1 30 15 Richman Richman Richman 65 Richman Richman 450 98 -1 349 -1 513 -1 161 297 Richman Richman Richman 147 274 -1 160 -1 58 -1 130 27 Richman 175 -1 -1 Richman 21 -1 Richman 65 Richman 247 356 Richman Richman -1 312 -1 276 Rich...
result:
wrong answer 1st lines differ - expected: '1', found: '-1'