๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.59K photos
3 videos
95 files
10.2K 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
To h*ll with boring tech conferences!
Most tech conferences are just monologues. They promise the world but fail to deliver.
Itโ€™s time to change the experience of tech conferences.

Presenting the O(1) Tech Conference by Masai
- Networking with techies from companies like Google & Amazon
- Get customised career guidance and
- Real-word insights to transition your career

This event will take place in Bangalore on the 28th of October. The eligibility criteria is: You must have 1+ years of experience of working in tech.

Register now: https://aqzy.short.gy/nHsZfM

Indiaโ€™s true tech conference is finally here!


Offline event in Bangalore on 28th October, if you are in Bangalore, I will highly recommend to join this ๐Ÿ˜‡โค๏ธ
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int minOperations(int k, vector<int>& locks) {
    int n = locks.size();
    int answer = 1e9;
    for (int target = 1; target <= k; ++target) {
        int operations = 0;

        for (int j = 0; j < n; ++j) {
            if (locks[j] == target) continue;
            int direct_op = abs(target - locks[j]);
            int threshold_op = k - locks[j] + target;

            operations += min(direct_op, threshold_op);
        }

        answer = min(answer, operations);
    }

    return answer;
}

int main() {
    int k, n;
    cin >> k >> n;
   
    vector<int> locks(n);
    for (int i = 0; i < n; ++i) {
        cin >> locks[i];
    }

    cout << minOperations(k, locks) << endl;

    return 0;
}
๐Ÿ‘1