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. 点开瞅瞅,再来几道Python面试题吧,Python面试题No20

    本面试题题库,由公号:非本科程序员 整理发布 第1题:如何理解 Django 被称为 MTV 模式? 这个题就是面向对象设计和设计模式的开始. 你可能比较熟悉的模式叫做: MVC.说是 Model V ...

  2. 【BZOJ2565】最长双回文串 (Manacher算法)

    题目: BZOJ2565 分析: 首先看到回文串,肯定能想到Manacher算法.下文中字符串\(s\)是输入的字符串\(str\)在Manacher算法中添加了字符'#'后的字符串 (构造方式如下) ...

  3. python常见的加密方式

    1.前言 我们所说的加密方式都是对二进制编码的格式进行加密,对应到python中,则是我妈们的bytes. 所以当我们在Python中进行加密操作的时候,要确保我们的操作是bytes,否则就会报错. ...

  4. NHibernate系列学习(三)-条件查询Criteria

    1.本笔记主要介绍Criteria的使用 2.效果界面 3.代码详情 namespace KimismeDemo { public partial class Form3 : Form { priva ...

  5. git的使用注意事项

    这里仅记录了下自己在初次使用git来管理项目的时候遇到的一些注意事项,记录下来备忘以下,以免下次又在这里花太多时间. 1. centos下面已经支持yum install git.来安装. 2. 安装 ...

  6. [Codeforces]Codeforces Round #490 (Div. 3)

    Mishka and Contest #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JU ...

  7. jQuery——自定义动画

    动画方法:animate(json,1000, function (){}) 参数说明:json代表属性设置,1000是动画时间,最后一个是回调函数,其中动画时间可选 属性支持:http://www. ...

  8. Centos 安装配置iscsi

    在测试oracle rac的时候用iscsi来模拟磁阵的(真的磁阵需要多路径软件),简单的记录下 #scsi server yum install scsi-target-utils service ...

  9. HDU_2212_水

    DFS Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  10. webstrom常用键

    常用快捷键—Webstorm入门指南 提高代码编写效率,离不开快捷键的使用,Webstorm拥有丰富的代码快速编辑功能,你可以自由配置功能快捷键. 快捷键配置 点击“File”-> “setti ...