Lab Da 1
Lab Da 1
assesment
int p=0;
float s;
sort(v3.begin(),v3.end());
reverse(v3.begin(),v3.end());
for(int i=0;i<n;i++){
if(cap>0 && v1[i]<=cap){
cap=cap-v1[i];
p+=v2[i];
cout<<"1.0 ";
}
else if(cap>0){
s=((float)cap/(float)v1[i]);
cout<<round(s*10)/10<<" ";
p+=v2[i]*s;
}
else{
cout<<"0.0 ";
break;
}
}
}
#include <iostream>
int i = 0, j, count = 0;
count++;
i = j;
if (count == k) {
break;
int main() {
int n, k;
cin >> n;
cin >> k;
return 0;
}
#include <iostream>
struct PlayerInfo {
int winnerIndex;
int worstIndex;
};
PlayerInfo findWinnerAndWorst(int scores[], int low, int high) {
if (low == high) {
PlayerInfo result;
return result;
int main() {
int n;
cin >> n;
int scores[n];
return 0;
}
#include <stdio.h>
return (a < b) ? a : b;
}
int carAssembly(int a[2][4], int t[2][3], int e[2], int x[2], int n) {
// Minimum time to build the car is the minimum of exit times from the two lines
}
int main() {
int n;
scanf("%d", &n);
scanf("%d", &a[i][j]);
scanf("%d", &t[i][j]);
}
scanf("%d", &e[i]);
scanf("%d", &x[i]);
printf("%d\n", minimumTime);
return 0;
}
#include <iostream>
#include <vector>
int m = s1.length();
int n = s2.length();
// Create a 2D vector to store the lengths of the longest common subsequences
} else {
string lcs;
int i = m, j = n;
i--;
j--;
i--;
} else {
j--;
return lcs;
int main() {
int len1;
int len2;
#include <iostream>
#include <vector>
using namespace std;
int m = s1.length();
int n = s2.length();
} else {
string lcs;
int i = m, j = n;
i--;
j--;
i--;
} else {
j--;
return lcs;
int main() {
int len1;
int len2;
return 0;
}
#include <iostream>
#include <vector>
K[i][w] = 0;
keep[i][w] = 1;
else
keep[i][w] = 0;
} else {
keep[i][w] = 0;
int i = n, w = W;
if (keep[i][w] == 1) {
selectedItems[i - 1] = 1;
w -= weights[i - 1];
i--;
}
// Print the solution
int main() {
int n, W;
cin >> n;
cin >> W;
return 0;
#include <iostream>
#include <vector>
if (board[i][col] == 1) {
return false;
if (board[i][j] == 1) {
return false;
if (board[i][j] == 1) {
return false;
return true;
if (row == n) {
// All queens are placed successfully
return true;
board[row][col] = 1;
board[row][col] = 0;
void solveNQueens(int n) {
if (!solveNQueensUtil(board, 0, n)) {
cout << "No solution exists for N = " << n << endl;
return;
int main() {
int n;
cin >> n;
solveNQueens(n);
return 0;
}
#include <iostream>
#include <climits>
int max_crossing_subarray(int arr[], int low, int mid, int high, int& max_left, int&
max_right) {
int sum_temp = 0;
max_left = mid;
sum_temp += arr[i];
left_sum = sum_temp;
max_left = i;
}
int right_sum = INT_MIN;
sum_temp = 0;
max_right = mid + 1;
sum_temp += arr[i];
right_sum = sum_temp;
max_right = i;
int max_subarray(int arr[], int low, int high, int& max_left, int& max_right) {
if (low == high) {
max_left = low;
max_right = high;
return arr[low];
max_left = left_low;
max_right = left_high;
return left_sum;
max_left = right_low;
max_right = right_high;
return right_sum;
} else {
max_left = cross_low;
max_right = cross_high;
return cross_sum;
int main() {
int a;
cin>>a;
int arr[a] ;
for(int i=0;i<a;i++){
cin>>arr[i];
return 0;
}
#include <iostream>
#include <cmath>
int m = n / 2;
// Recursive steps
int main() {
int x, y;
cin >> x;
cin >> y;
// Calculate and print the product using Karatsuba algorithm
return 0;