Codeforces|Leetcode|Codechef free solutions
رفتن به کانال در 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.
نمایش بیشتر4 317
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-137 روز
-5230 روز
آرشیو پست ها
#include <iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define pb push_back
void sol(){
int n,e;
cin>>n>>e;
vector<int> v(n);
for(auto &val:v) cin>>val;
v[0]+=e;
int ind = 0,m = v[0];
for(int i = 0;i<v.size();i++){
if(m<v[i]){
m = v[i];
ind = i;
}
}
int pre = 0;
vector<int> ans;
for(auto i = 0;i<v.size();i++){
int val = v[i];
pre+=val;
if(i==ind){
ans.push_back(0);
}
else{
if(pre>=m){
ans.push_back(i);
}
else{
ans.push_back(i+1);
}
}
}
for(auto &val:ans){
cout<<val<<" ";
}
cout<<endl;
return;
}
signed main()
{
int test;
cin>>test;
while(test--){
sol();
}
return 0;
}
Share this channel with your friends will upload more free codes in the channel😊😊
#include <iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define pb push_back
void sol(){
int n,k;
cin>>n>>k;
vector<int> ans;
int sum = 0;
for(int i = 1;i<=n;i++){
sum+=abs(i - (n-i+1));
ans.push_back(i);
// cout<<i<<endl;
}
if(k%2==1||sum<k){
cout<<"NO"<<endl;
}
else{
cout<<"YES"<<endl;
int ind = 0;
int N = n;
while((k)>(N-1)*2){
// cout<<k<<" "<<ind<<endl;
swap(ans[ind],ans[n-ind-1]);
k-=(N-1)*2;
N-=2;
ind++;
}
k/=2;
swap(ans[ind],ans[ind+k]);
int cal = 0;
for(auto i = 0;i<ans.size();i++){
cal+=abs(ans[i] - i-1);
cout<<ans[i]<<" ";
}
cout<<endl;
// cout<<cal<<endl;
}
return;
}
signed main()
{
int test;
cin>>test;
while(test--){
sol();
}
return 0;
}
#include <iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define pb push_back
void sol(){
int n,a,b;
cin>>n>>a>>b;
if(b<a){
cout<<n*a<<endl;
}
else{
int x = min(n,b - a);
int y = n - x;
int c = b-x;
int ans = y*a + (b*(b+1)/2) - (c*(c+1)/2);
cout<<ans<<endl;
}
return;
}
signed main()
{
int test;
cin>>test;
while(test--){
sol();
}
return 0;
}
Dm me today for any oa slots, today I am free for any coding rounds.
