-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from Coach-Academy/G2-Rady
week 09 problems
- Loading branch information
Showing
6 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemC.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
int t; | ||
cin >> t; | ||
while (t--){ | ||
string s , ss; | ||
cin >> s >> ss; | ||
map<char , bool > mp; | ||
for (char i : s){ | ||
mp[i] = 1; | ||
} | ||
bool ok = 0; | ||
for (char i : ss){ | ||
if (mp[i]){ | ||
ok = 1; | ||
} | ||
} | ||
if (ok) | ||
cout << "YES\n"; | ||
else cout << "NO\n"; | ||
} | ||
|
||
return 0; | ||
} |
31 changes: 31 additions & 0 deletions
31
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemD.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
string original = "qwertyuiopasdfghjkl;zxcvbnm,./"; | ||
map<char,int>mp; | ||
char c ; | ||
string s; | ||
cin >> c >> s; | ||
for (int i=0;i<original.size();i++){ | ||
mp[original[i]] = i ; | ||
} | ||
|
||
for (char i : s){ | ||
int idx = mp[i]; | ||
if (c=='R') | ||
cout << original[idx-1]; | ||
else | ||
cout << original[idx+1]; | ||
} | ||
|
||
return 0; | ||
} |
30 changes: 30 additions & 0 deletions
30
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemG.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
int n , m; | ||
cin >>n >> m; | ||
set<int>st; | ||
for (int i=0;i<n;i++){ | ||
int x; | ||
cin >> x; | ||
while (x--){ | ||
int y; | ||
cin >> y; | ||
st.insert(y); | ||
} | ||
} | ||
if (st.size()==m) | ||
cout << "YES"; | ||
else cout << "NO"; | ||
|
||
return 0; | ||
} |
33 changes: 33 additions & 0 deletions
33
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemI.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
int t; | ||
cin >> t; | ||
while (t--){ | ||
int n , r; | ||
cin >> n >> r; | ||
set<int>st; | ||
for (int i=0 , x;i<n;i++){ | ||
cin >> x; | ||
st.insert(x); | ||
} | ||
vector<int>v(st.begin() , st.end()); | ||
int d = 0 , cnt=0; | ||
for (int i=v.size()-1 ;i>=0;i--){ | ||
if (v[i] - d > 0) | ||
cnt++ ,d+=r ; | ||
} | ||
cout << cnt << "\n"; | ||
} | ||
|
||
return 0; | ||
} |
41 changes: 41 additions & 0 deletions
41
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemJ.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
int q; | ||
cin >> q; | ||
set<pair<int,int>>m , p; | ||
int id = 1; | ||
while (q--){ | ||
int op; | ||
cin >> op; | ||
if (op==1){ | ||
int x; | ||
cin >> x; | ||
p.insert({-x , id}) ; | ||
m.insert({id++ , x}); | ||
} | ||
else if (op==2){ | ||
auto it = *m.begin(); | ||
p.erase({-it.second , it.first}); | ||
m.erase(it); | ||
cout << it.first << " "; | ||
} | ||
else { | ||
auto it = *p.begin(); | ||
m.erase({it.second , -it.first}); | ||
p.erase(it); | ||
cout << it.second << " "; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
47 changes: 47 additions & 0 deletions
47
Level 1/CPU - Standard - L1 - C103/Practice G2/Week 09/ProblemK.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
#define el '\n' | ||
void fast () | ||
{ | ||
ios_base::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
|
||
} | ||
int main() | ||
{ | ||
fast(); | ||
int n, m; | ||
cin >> n >> m; | ||
map<int, int > mps, mpb; | ||
while (n--) | ||
{ | ||
char c ; | ||
int p, num ; | ||
cin >> c >> p >> num; | ||
if (c=='S') | ||
mps[p]+=num; | ||
else mpb[p]+=num; | ||
} | ||
vector<pair<int,int>> b, s; | ||
for (auto i : mpb) | ||
{ | ||
b.push_back({i.first, i.second}); | ||
} | ||
for (auto i : mps) | ||
{ | ||
s.push_back({i.first, i.second}); | ||
} | ||
sort(b.begin(),b.end()); | ||
sort(s.begin(),s.end()); | ||
reverse(b.begin(),b.end()); | ||
for (int i=min(m-1 , (int)s.size()-1);i>=0 ;i--){ | ||
cout << "S " << s[i].first << " " << s[i].second << el; | ||
} | ||
for (int i=0;i<b.size() && i<m;i++){ | ||
cout << "B " << b[i].first << " " << b[i].second <<el; | ||
} | ||
|
||
|
||
return 0; | ||
} |