1195: OS Job Scheduling

Time Limit: 2 Sec  Memory Limit: 128 MB

Submit: 106  Solved: 35

[

id=1195" style="color:rgb(26,92,200); text-decoration:none">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

search=%E9%83%91%E5%B7%9E%E5%A4%A7%E5%AD%A6%E7%AC%AC%E4%B8%83%E5%B1%8AACM%E5%A4%A7%E5%AD%A6%E7%94%9F%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E7%AB%9E%E8%B5%9B" style="color:rgb(26,92,200); text-decoration:none">郑州大学第七届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题)的更多相关文章

  1. 第七届ACM趣味程序设计竞赛第四场(正式赛) 题解

    Final Pan's prime numbers 题目连接: http://acm.uestc.edu.cn/#/problem/show/1272 题意 给你n,要求你在[4,n]范围内找到一个最 ...

  2. CDOJ 第七届ACM趣味程序设计竞赛第三场(正式赛) 题解

    宝贵资源 题目连接: http://acm.uestc.edu.cn/#/problem/show/1265 题意 平面上给n个点(n<=1000),要求找一个面积最小的正方形,将所有的点都囊括 ...

  3. 第 45 届国际大学生程序设计竞赛(ICPC)亚洲区域赛(济南)-L Bit Sequence

    题意 给你两个数l,m,大小为m的数组a,求[0,l]之间满足以下条件的数x的个数: 对于任何i输入[0,m-1],f(x+i)%2=a[i]:f(k):代表k在二进制下1的个数 m的范围<=1 ...

  4. 第六届福建省大学生程序设计竞赛(FZU2213—FZU2221)

    from:piaocoder Common Tangents(两圆之间的公公切线) 题目链接: http://acm.fzu.edu.cn/problem.php?pid=2213 解题思路: 告诉你 ...

  5. UESTC-第五届ACM趣味程序设计竞赛第四场(正式赛)--不完全解题报告

    比赛链接: http://acm.uestc.edu.cn/contest.php?cid=230 A.Police And The Thief ---UESTC 1913 简单博弈,先假设在警察先走 ...

  6. ZOJ 4100 浙江省第16届大学生程序设计竞赛 A题 Vertices in the Pocket 线段树+并查集

    正赛的时候完全没看这个题,事后winterzz告诉我他想出来的解法. 首先题意是给出n个点,m次操作. 操作有一种是连接两个点,另一种是求此时再为这个图连k条边,最少和最多能有几个联通块. 最少的求法 ...

  7. ZOJ 4103 浙江省第16届大学生程序设计竞赛 D题 Traveler 构造

    这个题,正赛的时候也没有过,不过其实已经有了正确的解法,可惜时间不多了,就没有去尝试. 题意是有n个点,i点能通向i-1,然后i和i*2.i*2+1互通. 请你构造一种路径从1能走完所有点,并且不重复 ...

  8. “浪潮杯”第九届山东省ACM大学生程序设计竞赛重现赛 C-Cities

    题目描述:There are n cities in Byteland, and the ith city has a value ai. The cost of building a bidirec ...

  9. FZU - 2295 Human life:网络流-最大权闭合子图-二进制优化-第九届福建省大学生程序设计竞赛

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 http://acm.fzu.edu.cn/problem.php?pid=2295 htt ...

随机推荐

  1. 如何解决error LNK2001(转载)

    转自:http://www.cnblogs.com/myzhijie/articles/1658545.html 解决外部符号错误:_main,_WinMain@16,__beginthreadex ...

  2. [转]linux下logrotate 配置和理解

    转自:http://blog.csdn.net/cjwid/article/details/1690101 对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以使用logrotat ...

  3. 【转】Linux账号管理之useradd

    转自:http://www.jb51.net/article/45848.htm Linux 系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然 ...

  4. Flume特点

    Flume 特点 1.可靠性 当节点出现故障时,日志能够被传送到其他节点上而不会丢失. Flume提供了三种级别的可靠性保障,从强到弱依次分别为: (1)  end-to-end(收到数据agent首 ...

  5. C# linq学习【转】

    在说LINQ之前必须先说说几个重要的C#语言特性 一:与LINQ有关的语言特性 1.隐式类型 (1)源起 在隐式类型出现之前, 我们在声明一个变量的时候, 总是要为一个变量指定他的类型 甚至在fore ...

  6. 3--Java NIO基础1

    一.NIO概述 1. BIO带来的挑战 BIO即堵塞式I/O,数据在写入或读取时都有可能堵塞,一旦有堵塞,线程将失去CPU的使用权,性能较差. 2. NIO工作机制 Java NIO由Channel. ...

  7. jQuery制作顶部与左侧锚点板块定位功能带动画跳转特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. POJ 3070 - 快速矩阵幂求斐波纳契数列

    这题并不复杂. 设$A=\begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}$ 由题中公式: $\begin{pmatrix}f(n+1) & ...

  9. C# 时间对比

    public bool IfTime(string StartTime, string EndTime) { DateTime dt1 = Convert.ToDateTime(StartTime); ...

  10. 内核调试-perf introduction

    perf概念 perf_event Perf_events是目前在Linux上使用广泛的profiling/tracing工具,除了本身是内核(kernel)的组成部分以外,还提供了用户空间(user ...