QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197113#6135. BooksHarryJWA 1ms3600kbC++23866b2023-10-02 11:39:102023-10-02 11:39:10

Judging History

This is the latest submission verdict.

  • [2023-10-02 11:39:10]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3600kb
  • [2023-10-02 11:39:10]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const int INF=0x3f3f3f3f;
const int N=1e5+10;
LL a[N];
int n,m;

void solve()
{
    cin>>n>>m;
    
    LL zero=0,miv=INF;
    
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        
        miv=min(miv,a[i]);
        if(!a[i]) zero++;
    }
    
    if(n==m) cout<<"Richman"<<endl;
    else if(!m) cout<<miv-1<<endl;
    else if(zero>m) cout<<"Impossible"<<endl;
    else
    {
        m-=zero;
        LL ans=0;
        
        for(int i=1;i<=n&&m;i++)
            if(a[i]) ans+=a[i],m--;
        
        cout<<ans<<endl;
    }
    
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int tt; cin>>tt;
    
    while(tt--) solve();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3600kb

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:

3
96
Richman
Impossible

result:

wrong answer 1st lines differ - expected: '6', found: '3'