i am a newbie to codechef and i daily use it but the thing is that when i have an solution which has the correct answers for the test case and still does not gets accepted , please help me with this thing. Like the problem “CFRTEST” my submission id is “77197095”.
i need a serious help with this thing please help me out my dear experts…
The main idea in this question is to count the days only once.
Let’s take an example of 1 1 2 3 4 5 6 7 7 8 9
. The first and second friends want a party on day 1
but Devu can only give party to any one friend on a single day. Hence he will only give party to the first friend. By this logic, the answer for the above question is 9
i.e. 1 2 3 4 5 6 7 8 9
.
You can use a set and store the days "di"
in it. Then just return the size of the set.
#include <iostream>
#include <set>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
set<int, greater<int> > D;
while (n--) {
int d;
cin >> d;
D.insert(d);
}
cout << D.size() << "\n";
}
return 0;
}