File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // main.cpp
3
+ // lecture 45
4
+ //
5
+ // Created by Prince Kumar on 25/07/19.
6
+ // Copyright © 2019 Prince Kumar. All rights reserved.
7
+ //
8
+ // codechef question --** Uncle johny ** ---- //
9
+
10
+
11
+ #include < iostream>
12
+ #include < vector>
13
+ #include < algorithm>
14
+ using namespace std ;
15
+ int main ()
16
+ {
17
+ int T; cin>>T;
18
+ while (T--)
19
+ {
20
+ int n; cin>>n;
21
+ vector<int > v;
22
+ for (int i=0 ;i<n;i++)
23
+ {
24
+ int x; cin>>x;
25
+ v.push_back (x);
26
+ // v.push_back(cin);
27
+ }
28
+ int k; cin>>k; // index of jhony unle song
29
+ // vector use --> indexing start from 0
30
+ int val = v[k-1 ]; // uncle jhony
31
+ sort (v.begin (),v.end ());
32
+ for (int i=0 ;i<n;i++)
33
+ {
34
+ if (v[i]==val)
35
+ {
36
+ cout<<i+1 <<endl;
37
+ break ;
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+
44
+
45
+
46
+
You can’t perform that action at this time.
0 commit comments