Skip to content

Commit 39f267c

Browse files
authored
Create A problem on sticks.CPP
1 parent 9b72dd6 commit 39f267c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
link:https://www.codechef.com/SEPT20B/problems/TREE2
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
int main() {
6+
int t;//number of test cases
7+
cin>>t;
8+
while(t--){
9+
int n;//input the number of sticks
10+
cin>>n;
11+
int a[n],i;// for each valid i, the initial height of the stick in the i-th holder is A[i]
12+
set<int>s;
13+
for( i=0;i<n;i++){// for each stick
14+
cin>>a[i];
15+
}
16+
for( i=0;i<n;i++){
17+
if(a[i]!=0){
18+
s.insert(a[i]);// avoid all those height which is repeated
19+
}
20+
21+
}
22+
23+
cout<<s.size()<<endl;//print the size of set
24+
}
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)