Increase your resume score so that it can pass through the ATS check. 300rs only
Preferably to an 90+ score in Resume Worded, delivered within a day..
2. Task Scheduling
Implement a prototype service for resource estimation.
Given a set of n tasks, the ith (0 ≤ i < n) task runs from time start[i] through end[i].
Implement a task scheduler method that finds the minimum number of machines required to complete the tasks. A task can be scheduled on exactly one machine, and one machine can run only one task at a time.
Example
Suppose n = 5, start = [1, 8, 3, 9, 6], end = [7, 9, 6, 14,7].
Consider the following task schedule. Times in parentheses are the inclusive start and end times for each job.
• Machine 1: [(1, 7), (8, 9)]
• Machine 2: [(3, 6), (9, 14)]
• Machine 3: [(6, 7)]
Here, the number of machines required is 3.
Function Description:
Complete the function getMinMachines in the editor below.
getMinMachines has the following parameters:
int start[n]: the start times of tasks int end[n]: the end times of tasks
Returns:
int: the minimum number of machines required to run all the tasks
Constraints:
• 15n≤2*10^5
• 1 ≤ start[if ≤ end[i] ≤ 10^9
Input Format for Custom Testing:
The first line contains an integer n, the number of tasks.
Each of the next n lines contains an integer start[i].
The next line contains the same integer n, the number of tasks.
Each of the next n lines contains an integer end[i].
• Sample Case 0:
Sample Input 0:
STDIN FUNCTION
------ -----------
5 → start[] size n = 5
2 → start[] = [2, 1, 5, 5, 8]
1
5
5
8
5 → end[] size n = 5
5 → end[] = [5, 3, 8, 6, 12]
3
8
6
12
Sample Output 0:
3
Explanation:
• Machine 1: [(1,3), (5,8)]
• Machine 2: [(2,5), (8, 12)]
• Machine 3: [(5,6)]
• Sample Case 1:
Sample Input 1:
STDIN FUNCTION
---- -----------
4 → start[] size n = 4
2 → start[] = [2, 2, 2, 2]
2
2
2
4 → end[] size n = 4
5 → end[] = [5, 5, 5, 5]
5
5
5
Sample Output 1:
4
Explanation:
• Machine 1: [(2, 5)]
• Machine 2: [(2, 5)]
• Machine 3: [(2, 5)]
• Machine 4: [(2, 5)]
I am now in 1032 rating. But nowadays it is hard for me to get ratings because of huge amounts of submissions. What should I do to perform better. My only target is to become specialist
Читать полностью…I have codeforces accounts for sale, expert, candidate master, master, grandmaster, dm me, payment via crypto
Читать полностью…I have codeforces accounts for sale, expert, candidate master, master, grandmaster, dm me, payment via crypto
Читать полностью…I have codeforces accounts for sale, expert, candidate master, master, grandmaster, dm me, payment via crypto
Читать полностью…#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int m = n;
map<int, int> freq;
int maxi = 0, ans = 0, counter = 0;
while (n--) {
int x, y;
cin >> x >> y;
freq[y]++;
counter++;
int adjustment = freq[y] - 2; // Equivalent to (mp[y] - 1 - 1)
ans -= (adjustment) * (adjustment + 1) / 2;
int current_count = freq[y] - 1;
ans += (current_count) * (current_count + 1) / 2;
maxi = max(maxi, freq[y]);
int solution = ans;
int adjustment_maxi = maxi - 1;
solution -= (adjustment_maxi) * (adjustment_maxi + 1) / 2;
int adjustment_full = maxi + (m - counter) - 1;
solution += (adjustment_full) * (adjustment_full + 1) / 2;
cout << solution << " ";
}
cout << endl;
}
return 0;
}