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. weak看iOS面试

    2013年 面试官:代理用weak还是strong? 我 :weak . 面试官:明天来上班吧 2014年 面试官:代理为什么用weak不用strong? 我 : 用strong会造成循环引用. 面试 ...

  2. 命令框中oracle dmp文件的导入和导出(仅做个人备忘)

    1.dmp文件导出 (全部)exp 用户名/密码 rows=y indexes=n compress=n buffer=65536 feedback=100000  file=F:\test.dmp ...

  3. Squirrel的安装(windows上Phoneix可视化工具)

    一.下载安装 下载地址:http://www.squirrelsql.org/下载所需版本       或者 从网址http://www.squirrelsql.org/下载相应版本的squirrel ...

  4. No operations allowed after connection closed--转

    https://www.jianshu.com/p/1626d41572f2 Spring boot的单数据源配置比较简单,只需要在application.properties配置相关的jdbc连接的 ...

  5. [转]Oracle11g链接提示未“在本地计算机注册“OraOLEDB.Oracle”解决方法

    本文转自:http://www.cnblogs.com/tomfang/archive/2013/05/25/3098454.html 当 用,Provider=OraOLEDB.Oracle方式访问 ...

  6. Spring Boot (26) RabbitMQ延迟队列

    延迟消息就是指当消息被发送以后,并不想让消费者立即拿到消息,而是等待指定时间后,消费者才拿到这个消息进行消费. 延迟队列 订单业务: 在电商/点餐中,都有下单后30分钟内没有付款,就自动取消订单. 短 ...

  7. 【Java基础】多态

    首先先来个总结: 什么是多态 面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点. 多态的定义:指允许不同类的对象对同一消 ...

  8. [ NOIP 1998 ] TG

    \(\\\) \(\#A\) 车站 火车从第\(1\)站开出,上车的人数为\(a\),然后到达第\(2\)站,在第\(2\)站有人上.下车,但上.下车的人数相同,因此在第\(2\)站开出时(即在到达第 ...

  9. [hihocoder][Offer收割]编程练习赛62

    方向 #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JUDGE #include &qu ...

  10. Hibernate中使用子查询

    子查询:   子查询是SQL语句中非常重要的功能特性,它可以在SQL语句中利用另外一条SQL语句的查询结果,在Hibernate中HQL查询同样对子查询功能提供了支持.   如下面代码所示: List ...