QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94924#6135. BooksGeorge_Plover#WA 2ms3724kbC++14596b2023-04-08 12:23:442023-04-08 12:23:46

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 12:23:46]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3724kb
  • [2023-04-08 12:23:44]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
const int N=100005;
int a[N],n,m;
void Main()
{
    scanf("%d%d",&n,&m);
    int cnt=0;
    For(i,1,n)scanf("%d",a+i),cnt+=a[i]==0;
    m-=cnt;
    if(m+cnt==n){printf("Richman\n"); return;}
    if(m<0){printf("Impossible\n"); return;}
    ll s=0; cnt=0;
    For(i,1,n)
        if(a[i]>0)
        {
            cnt++;
            if(cnt<=m+1)s+=a[i];
        }
    printf("%lld\n",s-1);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)Main();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3724kb

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
99
Richman
Impossible

result:

wrong answer 2nd lines differ - expected: '96', found: '99'