QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#267282#6135. Booksyujie3WA 59ms4296kbC++14822b2023-11-27 04:06:052023-11-27 04:06:06

Judging History

This is the latest submission verdict.

  • [2023-11-27 04:06:06]
  • Judged
  • Verdict: WA
  • Time: 59ms
  • Memory: 4296kb
  • [2023-11-27 04:06:05]
  • Submitted

answer

#include<bits/stdc++.h>
#define fast() ios::sync_with_stdio(false); cin.tie(nullptr),cout.tie(nullptr);
#define int long long

using namespace std;

const int N = 1e5 + 7;
int a[N];
int n,m;

void solve(){
	cin >> n >> m;
	int zero = 0;
	for(int i = 0;i < n;i ++){
		cin >> a[i];
		if(a[i] == 0) zero ++;
	}
	if(m == n){
		cout << "Richman" << endl;
		return;
	}	
	if(zero <= m){
		int sum = 0;
		int cnt = 0;
		for(int i = 0;i < n && cnt < m - zero;i ++){
			if(!a[i]) continue;
			else{
				sum += a[i];
				cnt ++;
			}
		} int mn = 1e9;
		for(int i = cnt;i < n;i ++){
			if(a[i]) mn = min(a[i],mn);
		} sum += mn - 1;
		cout << sum << endl;
	} else{
		cout << "Impossible" << endl;
	}
}

signed main(){
	fast();
	int _t; cin >> _t;
	while(_t --){
		solve();
	} return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3384kb

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: 59ms
memory: 4296kb

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
0
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
Richman...

result:

wrong answer 183rd lines differ - expected: '108', found: '82'