File tree Expand file tree Collapse file tree 3 files changed +98
-0
lines changed
Codeforces/After Placement Expand file tree Collapse file tree 3 files changed +98
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ written by Pankaj Kumar.
3+ country:-INDIA
4+ */
5+ #include < bits/stdc++.h>
6+ using namespace std ;
7+ typedef long long ll;
8+
9+
10+ int solve (){
11+ int n,m;
12+ cin>>n>>m;
13+ cout<<max (n,m)+1 <<endl;
14+ return 0 ;
15+ }
16+ int main ()
17+ {
18+ int testCase=1 ;
19+ cin>>testCase;
20+ while (testCase--){
21+ solve ();
22+ }
23+ return 0 ;
24+ }
Original file line number Diff line number Diff line change 1+ /*
2+ written by Pankaj Kumar.
3+ country:-INDIA
4+ */
5+ #include < bits/stdc++.h>
6+ using namespace std ;
7+ typedef long long ll;
8+
9+
10+ int solve (){
11+ int n,k,temp;
12+ cin>>n>>k;
13+ map<int , int > m;
14+
15+ for (int i=0 ;i<n;i++){
16+ cin>>temp;
17+ m[temp]++;
18+ }
19+ vector<int > v;
20+ for (auto x:m){
21+ v.push_back (x.second );
22+ }
23+ sort (v.begin (),v.end ());
24+ int ans=v.size ();
25+ // cout<<"ans "<<ans<<endl;
26+
27+ if (k==0 ){
28+ cout<<ans<<endl;
29+ return 0 ;
30+ }
31+
32+ for (int i=0 ;i<v.size ();i++){
33+ k-=v[i];
34+ if (k<0 ){
35+ break ;
36+ }
37+ ans--;
38+ }
39+ cout<<max (ans,1 )<<endl;
40+ return 0 ;
41+ }
42+ int main ()
43+ {
44+ int testCase=1 ;
45+ cin>>testCase;
46+ while (testCase--){
47+ solve ();
48+ }
49+ return 0 ;
50+ }
Original file line number Diff line number Diff line change 1+ class Solution {
2+ public:
3+ char find_mirror (char ch) {
4+ return ' a' + ' z' - ch ;
5+ }
6+ long long calculateScore (string s) {
7+ map<char , set<int >> mp;
8+
9+ long long score = 0 ;
10+ for (int i=0 ; i < s.size () ; i++) {
11+ char mir = find_mirror (s[i]);
12+
13+ if ( mp.find (mir) != mp.end () && mp[mir].size () > 0 ) {
14+ auto it = mp[mir].rbegin () ;
15+ score += i - *it ;
16+ mp[mir].erase (*it) ;
17+ }
18+ else {
19+ mp[s[i]].insert (i) ;
20+ }
21+ }
22+ return score ;
23+ }
24+ };
You can’t perform that action at this time.
0 commit comments