QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103305 | #6135. Books | Yanagi_Origami# | WA | 0ms | 3580kb | C++20 | 777b | 2023-05-05 06:38:07 | 2023-05-05 06:38:10 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e6+5;
int a[N],n,m;
void solve(){
scanf("%d%d",&n,&m);
rep(i,1,n) scanf("%d",a+i);
if(m>=n){
puts("Richman");
return ;
}
int c=0; ll ans=0;
rep(i,1,n) if(a[i]==0) c++;
if(c>m){
puts("impossible");
return ;
}
m-=c;
int p=1,Min=1e9+7;
while(m>0){
if(a[p]!=0) ans+=a[p],m--;
p++;
}
rep(i,p,n){
Min=min(Min,a[i]);
}
ans+=Min-1;
printf("%lld\n",ans);
}
int main(){
int T; scanf("%d",&T);
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3580kb
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:
wrong answer 4th lines differ - expected: 'Impossible', found: 'impossible'