codesolvediscuss | Unsorted

Telegram-канал codesolvediscuss - Codeforces solutions | CodeSolve | discussion

1582

Subscribe to a channel

Codeforces solutions | CodeSolve | discussion

#include <bits/stdc++.h>

using namespace std;
#define int long long
int32_t main() {
int t;
cin >> t;
while (t--) {
int n, d, k;
cin >> n >> d >> k;
vector<pair<int, int>> jobs(k);
for (int i = 0; i < k; i++) {
cin >> jobs[i].first >> jobs[i].second;
}

auto calc_overlap = [&](int start) {
int count = 0;
for (auto job : jobs) {
if (max(job.first, start) <= min(job.second, start + d - 1)) {
count++;
}
}
return count;
};

int max_overlap = 0, min_overlap = k + 1;
int best_brother = 1, best_mother = 1;

for (int i = 1; i <= n - d + 1; i++) {
int overlap = calc_overlap(i);
if (overlap > max_overlap) {
max_overlap = overlap;
best_brother = i;
}
if (overlap < min_overlap) {
min_overlap = overlap;
best_mother = i;
}
}

cout << best_brother << " " << best_mother << endl;
}
return 0;
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

SHARE GROUP FOR D SOLUTION

Читать полностью…

Codeforces solutions | CodeSolve | discussion

हिंदू मूर्ख मूर्ख हैं

Читать полностью…

Codeforces solutions | CodeSolve | discussion

уже ждем дохуя, индус работай

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Q2 anyone I am getting WA in test 2

Читать полностью…

Codeforces solutions | CodeSolve | discussion

else if (a[i] == 0 && robin > 0)

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;

    while (t--) {
        long long n, k;
        cin >> n >> k;

        long long start = max(1LL, n - k + 1);
        long long end = n;

        long long oddCount = 0;
       
        if (start % 2 == 1) {
            oddCount = (end - start) / 2 + 1;
        } else {
            oddCount = (end - start + 1) / 2;
        }

        if (oddCount % 2 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

B solution

Читать полностью…

Codeforces solutions | CodeSolve | discussion

CodeForces Div3🔥🔥

A Done✅✅

Dm me for paid sol

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Master card 1 and 2 both done ✅ ping me
🔥🔥🔥


Master card 1 and 2 both done ✅ ping me🔥🔥🔥



🔥🔥🔥Master card 1 and 2 both done ✅ ping me🔥🔥🔥

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Oa help available atlassian and deshaw

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Today's Div. 3 solutiosn will be avaible!!!

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anyone help me with amazon oa

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anyone help with atlassian today 🙏🏻🙏🏻

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Meta Hacker Cup anyone??

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Kya cheating kr rahe tum matherchodo

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Can anyone only hint me D, just hint

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include<bits/stdc++.h>
using namespace std;

const int INF = 1e18;

// Function to check if adding "additionValue" will make more than half of the elements below the new average
bool isValidMidpoint(int n, vector<int>& array, int totalSum, int additionValue) {
vector<int> newArray = array; // Copy of the original array
newArray[n-1] += additionValue; // Add the value to the last element
int newSum = totalSum + additionValue;
double newAverage = newSum / (2.0 * n); // New average based on the new total sum
int countBelowAverage = 0;

for (int i = 0; i < n; i++) {
if (newAverage > newArray[i]) {
countBelowAverage++;
}
}
return countBelowAverage > n / 2;
}

// Function to perform binary search to find the minimum addition value
int findMinimumAdditionValue(int n, vector<int>& array, int totalSum) {
int left = 0, right = INF, bestAddition = -1;

while (left <= right) {
int midpoint = left + (right - left) / 2;

if (isValidMidpoint(n, array, totalSum, midpoint)) {
bestAddition = midpoint;
right = midpoint - 1; // Try for a smaller value
} else {
left = midpoint + 1; // Try for a larger value
}
}

return bestAddition;
}

// Function to process each test case
void processTestCase() {
int n;
cin >> n;
int totalSum = 0;
vector<int> array(n);

for (int i = 0; i < n; i++) {
cin >> array[i];
totalSum += array[i];
}

// If the array is too small, output -1
if (n == 1) {
cout << -1 << endl;
return;
}
if(n == 2)
{
cout << -1 << endl;
return;
}
// Sort the array for easier comparison
sort(array.begin(), array.end());

// Calculate the initial average
int countBelowAverage = 0;



// Find the minimum addition value using binary search
int result = findMinimumAdditionValue(n, array, totalSum);
cout << result << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int testCases;
cin >> testCases;

while (testCases--) {
processTestCase();
}

return 0;
}


C solution and write long long instead of int everywhere

Читать полностью…

Codeforces solutions | CodeSolve | discussion

#include<bits/stdc++.h>
using namespace std;
void solve(){
int total_remaining=0;
int n,k;
int ans=0;
cin>>n>>k;
vector<int>a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}

for(int i=0;i<n;i++){
if(a[i]>=k){
total_remaining+=a[i];
}
else if(a[i]==0 && total_remaining>0){
total_remaining--;
ans++;
}
}
cout<<ans<<endl;

}
int main(){
int t;cin>>t;
while(t--){
solve();
}
}

Читать полностью…

Codeforces solutions | CodeSolve | discussion

CodeForces Div3🔥🔥

C.    Done✅✅

C.  Done✅✅

Dm me for paid soln

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Mine not working this

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Atlassian codes done ✅✅

Question 1 - Even ODD
Question 2
- Rearrange Students

Dmm

Читать полностью…

Codeforces solutions | CodeSolve | discussion

CodeForces Div3🔥🔥

A Done✅✅

B Done✅✅

Dm me for paid soln

Читать полностью…

Codeforces solutions | CodeSolve | discussion

A solution just go 1 to n in array and if a[i] >= k robin += a[i] else if a[i] == 0 count++ robin - - and at last cout « count « endl

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Master card 1 and 2 both done ✅ ping me



Master card 1 and 2 both done ✅ ping me

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Mastercard on campus help??

Читать полностью…

Codeforces solutions | CodeSolve | discussion

I need help for online assesment
For zscalar company can you help me question will from dp,graph

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Div3 milega kya aaj?

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Getting error in the output file in meta cup

Читать полностью…

Codeforces solutions | CodeSolve | discussion

Interviewer ke samne hago he pila pila

Читать полностью…

Codeforces solutions | CodeSolve | discussion

ANYONE NEEDED 

CF EXPERT

ACCOUNT,THEN DMM ME,
ONLY SERIOUS BUYER MSG ME


ANYONE NEEDED 5 ⭐ CODECHEF ACCOUNT,THEN DMM ME

CF EXPERT ACCOUNT FOR SELL

Читать полностью…
Subscribe to a channel