QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492891#6135. Books122WA 204ms4188kbC++141.3kb2024-07-26 16:52:362024-07-26 16:52:38

Judging History

This is the latest submission verdict.

  • [2024-07-26 16:52:38]
  • Judged
  • Verdict: WA
  • Time: 204ms
  • Memory: 4188kb
  • [2024-07-26 16:52:36]
  • Submitted

answer

#include <iostream> 
#include<vector>
#include<string>
#include<algorithm>
#include <cstring>
#include<ctype.h>
#include<set>
#include<map>
#include<cmath>
#include<climits>
#include<stack>
#include<list>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#define IOS ios::sync_with_stdio(false);cin.tie(0); 
#define maxn 200000+5
#define ll long long
using namespace std;
#define maxn 1000000+5
#define ll long long

using namespace std;


int main() {
    int t;
    cin >> t;
    while (t--)
    {
       
        int n, m;
        cin >> n >> m;
        vector<int>a(n + 1, 0);

        int sum = 0; int cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
            if (a[i] == 0) cnt++;
        }
        if (n == m) {
            cout << "Richman"<<endl;
            continue;
        }
        if (cnt >= m&&cnt)
        {
            
            cout << "Impossible"<<endl;
            continue;
        }
        sort(a.begin() + 1, a.begin() + n + 1);
        int cnt1 = m + 1;
        sum = 0;
        for (int i = 1; i <= n; i++)
        {
            if (i == m + 1)

            {
                sum += a[i] - 1; break;
            }
            else sum += a[i];
        }
        cout << sum << endl;
        continue;
       
    }
    
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

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: 204ms
memory: 4188kb

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
Impossible
Impossible
276447231
38
56
Richman
97
411
Richman
24
50
98
30
15
Richman
Richman
Richman
36
Richman
Richman
450
24
44
349
34
475
28
33
238
Richman
Richman
Richman
51
274
2
160
76
47
91
71
3
Richman
125
32
15
Richman
21
26
Richman
7
Richman
206
266
Richman
Richman
60
286
62
257
Richman
6...

result:

wrong answer 2nd lines differ - expected: '0', found: 'Impossible'