Professional Documents
Culture Documents
His coding:
// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and end
s there.
//
#include <iostream>
#include <vector>
#include <algorithm>
class TaskExecutor {
int no_lines = 2;
std::vector<vector<int>> time_t_switch;
std::vector<int> entries,exits;
std::vector<int> execution_times;
int S[2][5];
TaskExecutor(vector<vector<int>> t, vector<int> a):time_t_switch(t) {
for (int i = 0; i < 5; i++) {
S[0][i] = i + 1;
S[1][i] = i + 2;
}
}
bool Station[2] = { false,false };
//int schedule() {
// for (int i = 0; i < 5; i++) {
// if()
// }
//}
int execute(vector<int> a) {
int time = 0;
for (int i = 0; i < no_lines; i++) {
if (Station[i] == false) {
Station[i] = true;
for (int j = 0; j < 5; j++) {
int other_line = i == 0 ? 1 : 0;
time += a[i + 1] + std::min(S[i + 1][j], S[i + 1][j] + time_t_switch[i][other_line]);
}
}
}
return time;
//line i
}
//std::queue<Job> Q;
//thread
};
int main()
{
// input for S[i] for each line - 1d
// time for switching between i,j, - 2d
// consider n = 5;
int n = 5;
std::vector<vector<int>> time_to_switch = { {1,1,2,3,2},{1,4,5,3,1} };
std::vector<int> a = { 1,2,3,4,5 };
TaskExecutor t()