Codeforces|Leetcode|Codechef free solutions
Open in Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
Show more4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
F will be posted when 2750 subscribers will be reached
Enjoy and subscribe the channel for more free codes 🥳🥳🥳🥳
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll kitne_cases_hain;
kitne_cases_hain=1;
cin>>kitne_cases_hain;
while(kitne_cases_hain--){
ll n;
cin>>n;
string s;
cin>>s;
if(s[0]=='0'){
for(int i=0;i<2*n;i++){
if(s[i]=='1'){
s[i]='0';
}else{
s[i]='1';
}
}
}
vector <ll> v;
ll cnt;
ll flag=0;
ll p;
for(int i=0;i<2*n;i++){
if(s[i]=='0'){
v.push_back(i);
}
if(s[i]!=s[2*n-i-1]){
flag=1;
break;
}
}
if(flag){
cout<<"1\n";
cout<<2*n<<"\n";
continue;
}
if(v.size()==0){
cout<<"-1\n";
}else{
cnt=2*n-1-v.back();
for(int i=v.size()-1;i>=1;i--){
if(v[i]-v[i-1]-1!=cnt){
flag=1;
cout<<"2\n";
cout<<v[i-1]+1<<" "<<2*n-1-v[i-1]<<"\n";
break;
}
}
if(flag==0){
cout<<"2\n";
cout<<v[v.size()-2]+2<<" "<<2*n-2-v[v.size()-2]<<"\n";
}
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n,a[102],b[102],answer,Q[102][20001];
void dfs(int idx,int x,int y) {
if(idx==n+1) {
answer=max(answer,min(x,y));
return;
}
if(Q[idx][x]>=y&&Q[idx][x]!=0) return;
Q[idx][x]=y;
dfs(idx+1,x+a[idx],y);
dfs(idx+1,x,y+b[idx]);
}
void solve() {
cin >> n;answer=0;
for(int i=1;i<=n;++i)
for(int j=0;j<20001;++j)
Q[i][j]=0;
for(int i=1;i<=n;++i) cin >> a[i];
for(int i=1;i<=n;++i) cin >> b[i];
dfs(1,0,0);
cout << answer << endl;
}
signed main() {
int T;cin >> T;
while(T--) solve();
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,s,x,c0,c1,c2;
void solve() {
cin >> n;s=c0=c1=0;
for(int i=1;i<=n;++i) {
cin >> x;
c0+=(x==0);
c1+=(x==1);
c2=min(c0,c1);
c0-=c2;c1-=c2;s+=c2;
}
cout << s+c1/3 << endl;
}
signed main() {
int T;cin >> T;
while(T--) solve();
}
void MAIN()
{
ll n, a = 'a', ans = 0;
string s1,s2;
cin>>n>>s1>>s2;
vi f1(26,0), f2(26,0);
loopi(0,n)
{
f1[s[i] - a]++;
f2[s2[i] - a]++;
}
loopi(0,26)
{
ans = max(ans, min(f1[i],f2[i]));
}
cout<
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rojka ll n;cin>>n;ll a[n];for(int i=0;i<n;i++){cin>>a[i];}
ll maxmax(ll a,ll b,ll c){
return max(a,max(b,c));
}
ll minmin(ll a,ll b,ll c){
return min(a,min(b,c));
}
ll gcd(ll a, ll b){
return __gcd(a,b);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll kitne_cases_hain;
kitne_cases_hain=1;
cin>>kitne_cases_hain;
while(kitne_cases_hain--){
ll n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
vector <ll> v;
v.push_back(1);
for(int i=1;i<n-1;i++){
if(a[i]>a[i-1] && a[i]>a[i+1]){
v.push_back(i+1);
}
}
v.push_back(n);
ll ans=0;
ll cnt;
for(int i=1;i<v.size();i++){
cnt=v[i]-v[i-1]+1;
ans+=(cnt*(cnt+1))/2;
}
ans-=(v.size()-2);
cout<<ans<<"\n";
}
return 0;
}
Repost from Codeforces|Leetcode|Codechef free solutions
Contact me before your coding round and book your slot
100% solutions guaranteed 🔥🔥🔥🔥🔥
‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️
Solution for all companies will be available
🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁
Get a special discount
Dm @Cpsoln
‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️
Don't trust on other telegram channels they will take money and block you
Repost from Codeforces|Leetcode|Codechef free solutions
Contact me before your coding round and book your slot
100% solutions guaranteed 🔥🔥🔥🔥🔥
‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️
Solution for all companies will be available
🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁🎁
Get a special discount
Dm @Cpsoln
‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️‼️
Don't trust on other telegram channels they will take money and block you
