๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
The Undefeated Magician

def is_possible(N, X):
    attempts = 0
    while N > 0:
        N >>= 1
        attempts += 1
    return attempts <= X

def min_attempts(N):
    left, right = 0, N
    result = -1
    while left <= right:
        mid = (left + right) // 2
        if is_possible(N, mid):
            result = mid
            right = mid - 1
        else:
            left = mid + 1
    return result

T = int(input().strip())
for _ in range(T):
    N = int(input().strip())

    print(min_attempts(N))
def is_satisfied(N, W, R, weights):
    # Check if the weight of the rod itself is at least W
    if abs(R) >= W:
        return "waku waku"
   
    # Check if Aditya Sama can balance the weights symmetrically
    left_sum = 0
    right_sum = 0
    for weight in weights:
        if weight < 0:
            left_sum += abs(weight)
        else:
            right_sum += weight
   
    if left_sum == right_sum and left_sum >= W:
        return "waku waku"
    else:
        return "orewa kanashii desu"

N, W, R = map(int, input().split())
weights = list(map(int, input().split()))

print(is_satisfied(N, W, R, weights))

Aditya-Sama and Gym
๐Ÿ‘1
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int T;
    cin >> T;
    while (T--) {
        int N;
        long long K;
        cin >> N >> K;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        int maxLength = -1;
        long long sum = 0;
        int left = 0;

        for (int right = 0; right < N; ++right) {
            sum += A[right];
            int length = right - left + 1;

            while (sum * length > K && left < right) {
                sum -= A[left];
                left++;
                length = right - left + 1;
            }

            if (sum * length <= K && length > 1) {
                maxLength = max(maxLength, length);
            }
        }

        cout << maxLength << endl;
    }
    return 0;
}

Shiv and Subarray โœ…
โค1