QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103306 | #6135. Books | Yanagi_Origami# | WA | 111ms | 3932kb | C++20 | 777b | 2023-05-05 06:38:56 | 2023-05-05 06:38:58 |
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=1e5+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: 100
Accepted
time: 0ms
memory: 3584kb
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: 111ms
memory: 3932kb
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 -1 Impossible 99999999999999 192 80 Richman 97 460 Richman 24 163 98 30 15 Richman Richman Richman 65 Richman Richman 450 98 44 349 34 513 28 161 297 Richman Richman Richman 147 274 2 160 76 58 91 130 3 Richman 175 32 15 Richman 21 26 Richman 65 Richman 247 356 Richman Richman 60 312 62 276 Richma...
result:
wrong answer 2nd lines differ - expected: '0', found: '-1'