期限付きのジョブシーケンス問題
この問題では、与えられた仕事のリストがあります。リストには、各ジョブの期限と利益も示されています。すべてのジョブには1単位の時間がかかるため、ジョブの最小期限は1です。一度に1つのジョブしかスケジュールできない場合は、利益を最大化します。
この問題を解決するために、一連のジョブのすべてのサブセットが生成され、個々のサブセットが実行可能かどうかがチェックされます。また、生成されたすべての実行可能なサブセットの最大利益を追跡します。
このアルゴリズムの時間計算量はO(n ^ 2)
です。入力と出力
Input:
A list of jobs with job id, deadline and profit. And the number of jobs n.
{('a', 2, 100), ('b', 1, 19), ('c', 2, 27), ('d', 1, 25), ('e', 3, 15)}
n = 5
Output:
Following is maximum profit sequence of job sequence: c a e アルゴリズム
jobSequence(jobList, n)
入力- ジョブのリストとリストに存在するジョブの数。
出力- 順序、仕事の進め方。
Begin sort the jobs in jobList according to their profit create a list of job sequence and slot to track free time slots initially make all slots are free for all given jobs i do for all jobs in the list from ending of the list do if slot[j] is free then jobSequence[j] := i make slot[j] := fill break the loop done done for all slots when it is not free do print id of job using jobList[jobSequence[i]] done End
例
#include<iostream>
#include<algorithm>
using namespace std;
struct Job {
char id;
int deadLine;
int profit;
};
bool comp(Job j1, Job j2) {
return (j1.profit > j2.profit); //compare jobs based on profit
}
int min(int a, int b) {
return (a<b)?a:b;
}
void jobSequence(Job jobList[], int n) {
sort(jobList, jobList+n, comp); //sort jobList on profit
int jobSeq[n]; // To store result (Sequence of jobs)
bool slot[n]; // To keep track of free time slots
for (int i=0; i<n; i++)
slot[i] = false; //initially all slots are free
for (int i=0; i<n; i++) { //for all given jobs
for (int j=min(n, jobList[i].deadLine)-1; j>=0; j--) { //search from last free slot
if (slot[j]==false) {
jobSeq[j] = i; // Add this job to job sequence
slot[j] = true; // mark this slot as occupied
break;
}
}
}
for (int i=0; i<n; i++)
if (slot[i])
cout << jobList[jobSeq[i]].id << " "; //display the sequence
}
int main() {
Job jobList[] = {{'a',2,100}, {'b',1,19}, {'c',2,27},{'d',1,25},{'e',3,15}};
int n = 5;
cout << "Following is maximum profit sequence of job sequence: ";
jobSequence(jobList, n);
} 出力
Following is maximum profit sequence of job sequence: c a e
-
[修正済み] Sony WH-1000XM4 モントレーの問題
この記事では、Monterey の問題で Sony WH-1000XM4 の問題を解決するのに役立つ最も可能性の高い修正を紹介しました。 Mac ユーザーが最新の macOS Monterey にアップデートするとすぐに、多くの問題に襲われます。これらの問題は、Mac の効率とパフォーマンスに影響します。 Apple は新しいアップデートでほとんどの問題に対処しましたが、まだ多くの問題が存在し、Mac とそれに接続されたアクセサリの動作を妨げています。 最近、多くのユーザーが、Sony WH-1000XM4 を Mac に接続する際に問題が発生しているいくつかのオンライン フォーラムについ
-
WhatsApp の一般的な問題を解決する
WhatsApp が機能しない、または応答しませんか?心配しないでください。このガイドでは、Android での WhatsApp に関する最も一般的な問題のいくつかを修正します。 現在、WhatsApp という名前はほとんど紹介する必要がありません。現在世界で最も広く使われているチャットアプリです。 WhatsAppの人気は明らかに比類のないものです。無料で、シンプルで、非常に使いやすいです。これらの機能により、あらゆる年齢層の人々が WhatsApp にアカウントを持っています。音声通話、ビデオ通話、電話会議、画像、動画、ドキュメント、ファイルの共有、場所や連絡先の送信などのリソースに