Skip to content

Instantly share code, notes, and snippets.

@rhlmshr
Created September 26, 2017 16:46
Show Gist options
  • Save rhlmshr/8f74d7a02f8a21765d5a6a6933b6cbe6 to your computer and use it in GitHub Desktop.
Save rhlmshr/8f74d7a02f8a21765d5a6a6933b6cbe6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <map>
using namespace std ;
/* by Rahul Mishra
on 26/09 */
int distinct_value(int arr[], int n) {
map<int, int> freq ;
int counter = 0 ;
for(int i = 0; i < n; i++) {
if(freq[arr[i]] == 0) {
counter++ ;
} else if(freq[arr[i]] == 1) {
counter-- ;
}
freq[arr[i]]++ ;
}
return counter ;
}
int main() {
int T, N, X ;
cin >> T ;
int result[T] ;
for(int i = 0; i < T; i++) {
cin >> N >> X ;
int arr[N] ;
for(int j = 0; j < N; j++) {
cin >> arr[j] ;
}
int val = distinct_value(arr, N) ;
if(val == X) {
result[i] = 0 ;
} else if(val < X) {
result[i] = 1 ;
} else {
result[i] = 2 ;
}
}
for(int i = 0; i < T; i++) {
if(result[i] == 0) {
cout << "Good" << endl ;
} else if (result[i] == 1) {
cout << "Bad" << endl ;
} else {
cout << "Average" << endl ;
}
}
}
@rhlmshr
Copy link
Author

rhlmshr commented Sep 26, 2017

page 1
page 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment