Created
September 26, 2017 16:46
-
-
Save rhlmshr/8f74d7a02f8a21765d5a6a6933b6cbe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 ; | |
} | |
} | |
} |
Author
rhlmshr
commented
Sep 26, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment