initial commit

This commit is contained in:
ShazidMahsrafi 2023-08-03 02:43:15 +06:00
parent 0e75028455
commit 19cd88d7d3
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,38 @@
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n, t;
cin >> n >> t;
string s;
cin >> s;
while (t--)
{
for (int i = 0; i < n - 1; ++i)
{
if (s[i] == 'B' && s[i + 1] == 'G')
{
char c;
c = s[i];
s[i] = s[i + 1];
s[i + 1] = c;
i++;
}
}
}
cout << s;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
// cin >> TC;
// cin.ignore();
while (TC--)
solve();
}

View File

@ -0,0 +1,30 @@
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n,h;
cin>>n>>h;
int w=0;
for(int i=0; i<n; ++i)
{
int x;
cin>>x;
if(x>h) w=w+2;
else w++;
}
cout<<w<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int TC = 1;
//cin >> TC;
//cin.ignore();
while (TC--) solve();
}