ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)

Posted gccbuaa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)相关的知识,希望对你有一定的参考价值。

1195: OS Job Scheduling

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 106  Solved: 35
[Submit][Status][Web Board]

Description

OS(Operating System) is to help user solve the problem, such as run job(task).A multitasking OS is one that can simultaneously interleave execution of more than one job .It means that, at the same time, more than one job waiting for being processed by the OS. But now that the OS is only one processor, a processor can only execute one job at the same time. So the OS will be decided at a time which one job be processed. Each job has three property: time(the time submit to the system), priority (Perform high priority) and length(the running time of job). In order to improve the throughput(the number of unit time processing jobs) about OS, there are several basic algorithms to solve this problem. They were explained in the following:  
 
FCFS: first come first service 
The jobs are executed on first come, first serve basis. It is easy to understand and implement, but it is poor in performance as average wait time is high. 
 
SJF: Shortest job first. 
It is the best approach to minimize waiting time, but impossible to implement. The processor should know in advance how much time process will take. 
 
PBS: Priority based scheduling 
Each process is assigned a priority. Process with highest priority is to be executed first and so on. Processes with same priority are executed on first come first serve basis. 
 
Today,  Chris‘s teacher gave him a homework: given n jobs and the time of each job submission to the system, use the method of FCFS(The first submit is executed first),to decide the order of the operation is performed. 
 
Chris get confused with this problem thoroughly, so he ask you for help. Please help him to solve this problem.

Input

There are multiple input data groups, for each input data group:
The first line of input an integer n (1≤n≤1000),the number of the job should to be handled. The next line contains n space-separated integer numbers. The i-th number ti (1≤i≤1000, 1≤ti≤1000)denotes the time of i-th  job be submitted. It is essential that ti≠tj(1≤i , j≤1000 && i≠j )

Output

For each input data group, print n space-separated integer numbers, the i-th number represents the i-th run jobs.

Sample Input

5
1 2 3 4 5
5
5 4 3 2 1
5
3 2 4 1 5

Sample Output

1 2 3 4 5
5 4 3 2 1
4 2 1 3 5

HINT

Source

郑州大学第七届ACM大学生程序设计竞赛


大概是上学期吧,那次比赛,水平太菜了,当时看到全英文都没敢做。

。。唉:-(

如今看看这题,简直简单啊!!

AC代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

struct fun
{
	int jobi;
	int t;
}job[1010];

bool cmp(fun a, fun b)
{
	return a.t<b.t;
}

int main()
{
	int T;
	while(scanf("%d", &T)!=EOF)
	{
		int i;
		for(i=1; i<=T; i++)
		{
			job[i].jobi=i;
			scanf("%d", &job[i].t);
		}
		sort(job+1, job+T+1, cmp);
		for(i=1; i<T; i++)
			printf("%d ", job[i].jobi);
		printf("%d\n", job[i].jobi);
	}
	return 0;
}


以上是关于ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)的主要内容,如果未能解决你的问题,请参考以下文章

@Schedul 中cron的命名规则

text cron schedul表达

记一次Laravel 定时任务schedul:run未执行的处理

K8S单master部署三:APIserver+Controller-Manager+Schedul

深入理解spark-两种调度模式FIFO,FAIR模式

Spring中使用Quartz