codesolvediscuss | Unsorted

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

1583

Subscribe to a channel

Codeforces solutions | CodeSolve | discussion

Bhai editorial dekh lena ab , unrated h contest yeh

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

Codeforces solutions | CodeSolve | discussion

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;

public class Main {

// Function to calculate the sum of an arithmetic sequence
static long findSum(long n, long a, long d) {
long result = n * (2 * a + (n - 1) * d);
result = result / 2;
return result;
}

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] data = br.readLine().split(" ");
int t = Integer.parseInt(data[0]); // Number of test cases
int index = 1;
ArrayList<String> results = new ArrayList<>();

for (int i = 0; i < t; i++) {
long n = Long.parseLong(data[index]); // Length of sequence
long k = Long.parseLong(data[index + 1]); // Start value
index += 2;

long low = k;
long high = k + n - 1;
long left = k;
long right = k + n - 1;
long position = 0;
int count = 0;

while (left <= right) {
count++;
long mid = (left + right) / 2;
long posSum = findSum(mid - low + 1, low, 1);
long negSum = findSum(high - mid, mid + 1, 1);

if (posSum <= negSum) {
position = mid;
left = mid + 1;
} else {
right = mid - 1;
}
}

long minDiff = Long.MAX_VALUE;
long result = position;

for (long j = position - 10; j <= position + 10; j++) {
if (j < low || j > high) continue;

long posSum = findSum(j - low + 1, low, 1);
long negSum = findSum(high - j, j + 1, 1);
long currentDiff = Math.abs(posSum - negSum);

if (currentDiff < minDiff) {
minDiff = currentDiff;
result = j;
}
}

results.add(String.valueOf(minDiff));
}

// Output results
for (String res : results) {
System.out.println(res);
}
}
}

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

Codeforces solutions | CodeSolve | discussion

Mine got accepted bro

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

Codeforces solutions | CodeSolve | discussion

Hahahah , unrated hogya contest

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

Codeforces solutions | CodeSolve | discussion

Unrated me agr solution same hue to khi ban pd gya to??

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

Codeforces solutions | CodeSolve | discussion

How can E second test case 5

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

Codeforces solutions | CodeSolve | discussion

Share your solutions

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

Codeforces solutions | CodeSolve | discussion

ABCDEF any exchange of G1 G3

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

Codeforces solutions | CodeSolve | discussion

bhai. DIV 4 jesa lag hi nhi rha

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

Codeforces solutions | CodeSolve | discussion

Khatam interest.
Chalo Ghar sab

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

Codeforces solutions | CodeSolve | discussion

contest is now unrated for all

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

Codeforces solutions | CodeSolve | discussion

I have ABCDEF for exchange for G1

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

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 x,y,k;
cin>>x>>y>>k;

int some;
int full;

if(x%k==0)
{
some=x/k;
}
else
{
some=(x/k)+1;
}

if(y%k==0)
{
full=y/k;
}
else
{
full=(y/k)+1;
}

// cout<<some<<" "<<full<<endl;

int mini=min(some,full);

int maxi=max(some,full);
int ans=mini+maxi+(maxi-mini);

if(some>full)
{
ans--;
}

cout<<ans<<endl;

}


return 0;
}

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

Codeforces solutions | CodeSolve | discussion

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

while (t--) {
ll x, y, k;
cin >> x >> y >> k;
ll moves = 0 ;
ll cx = 0 , cy = 0 ;

while (cx < x || cy < y) {
if (moves % 2 == 0) {
cx += std::min(k, x - cx);
} else {
cy += std::min(k, y - cy);
}
moves++;
}
cout<<moves<<"\n";
}

return 0;
}

C

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

Codeforces solutions | CodeSolve | discussion

Last case both are equal

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

Codeforces solutions | CodeSolve | discussion

#include <bits/stdc++.h>
#define ANTIHACK(x,k) ((x-k) + ((n^q^l*r)==855401101))
using namespace std;

int p = 1000000007;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);

long long ttt;
cin >> ttt;
nexttc:
while (ttt--) {
long long n, q;
cin >> n >> q;
vector<long long> a(2*n);
for (long long i=0; i<n; i++) {
cin >> a[i];
a[i+n] = a[i];
}

vector<long long> pref(2*n + 1, 0);
for (int i=1; i<=2*n; i++) {
pref[i] = a[i-1] + pref[i-1];
}

while (q--) {
long long l, r;
cin >> l >> r;
l--; r--;

long long ans = p + pref[n] * (r/n - l/n - 1);

ans += pref[l/n + n] - pref[l/n + l%n];
ans += pref[r/n + r%n + 1] - pref[r/n];

cout << ANTIHACK(ans, p) << endl;
}
}

return 0;
}

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

Codeforces solutions | CodeSolve | discussion

can you explain how its work?

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

Codeforces solutions | CodeSolve | discussion

Anyone say how E second test case?

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

Codeforces solutions | CodeSolve | discussion

I am not even attending contest🤣

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

Codeforces solutions | CodeSolve | discussion

Guys profile page bhi open nhi ho rha hai

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

Codeforces solutions | CodeSolve | discussion

English nahi maalum 🤣

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

Codeforces solutions | CodeSolve | discussion

Contest itself unrated

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

Codeforces solutions | CodeSolve | discussion

🔥🔥😂🔥😂🔥😂🔥🔥😂🔥😂🔥🔥😂🔥😂😂

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

Codeforces solutions | CodeSolve | discussion

That div 4 is unrated??

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

Codeforces solutions | CodeSolve | discussion

Due to the poor performance of the main site for a long period, Codeforces Round 971 (Div. 4) will be unrated. We apologize for the inconvenience.

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

Codeforces solutions | CodeSolve | discussion

Is cf working fine for u guys?

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

Codeforces solutions | CodeSolve | discussion

Why you send this code again???????????

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

Codeforces solutions | CodeSolve | discussion

No it won’t we have 2 sec

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

Codeforces solutions | CodeSolve | discussion

if (jj_x == jj_y &&(x % k == 0 || y % k == 0)) { count11--; }
cout << count11 <<"\n";

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

Codeforces solutions | CodeSolve | discussion

I think if both are equal than we will do max of both moves -1

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