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. Vue中nextTick()解析

    最近,在开发的时候遇到一个问题,让我对vue中nextTick()的用法加深了了解- 下面是在组件中引用的一个拖拽的组件: <vue-draggable-resizable class=&quo ...

  2. $P5018 对称二叉树$

    problem 一直忘记给这个题写题解了. 这题挺水的吧. 挺后悔当时没写出来. #ifdef Dubug #endif #include <bits/stdc++.h> using na ...

  3. Excel文件导入导出

    /**     * 导入Excel文件数据     *      * @param file 将要导入的Excel文件     * @param fileCheckKeyWord 用于判断导入文件是否 ...

  4. 使用less时的calc()函数问题

    在使用less时写 width:calc(100%-30px); 但在浏览器检查元素的时候总会显示width:70%; 可以在Less中把calc的写法改写成下面这样: width : calc(~& ...

  5. no斜体 背景图片坐标

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

  6. HDU_1087_Super Jumping! Jumping! Jumping!_dp

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  7. CPU内部组成及原理

    CPU,Central Processing Unit,翻译过来叫中央处理器.是一块超大规模的集成电路,是一台计算机的运算核心(Core)和控制核心( Control Unit).电脑中所有操作都由C ...

  8. php第二十一节课

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

  9. 洛谷——P3906 Geodetic集合

    P3906 Geodetic集合 题目描述 图G是一个无向连通图,没有自环,并且两点之间至多只有一条边.我们定义顶点v,u最短路径就是从v到u经过边最少的路径.所有包含在v-u的最短路径上的顶点被称为 ...

  10. 基本数据类型:布尔型(bool)和空值None

    一.布尔型(bool) 布尔类型很简单,就两个值 ,一个True(真),一个False(假), 主要用记逻辑判断: 一件事情成立就是True,不成立就是False,也可以将bool值归类为数字, 是因 ...