ZZUOJ-1195-OS Job Scheduling(郑州大学第七届ACM大学生程序设计竞赛E题)
1195: OS Job Scheduling
Time Limit: 2 Sec Memory Limit: 128 MB id=1195" style="color:rgb(26,92,200); text-decoration:none">Submit
Submit: 106 Solved: 35
[
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
Sample Output
HINT
Source
大概是上学期吧,那次比赛,水平太菜了,当时看到全英文都没敢做。
。。唉:-(
如今看看这题,简直简单啊!!
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题)的更多相关文章
- 第七届ACM趣味程序设计竞赛第四场(正式赛) 题解
Final Pan's prime numbers 题目连接: http://acm.uestc.edu.cn/#/problem/show/1272 题意 给你n,要求你在[4,n]范围内找到一个最 ...
- CDOJ 第七届ACM趣味程序设计竞赛第三场(正式赛) 题解
宝贵资源 题目连接: http://acm.uestc.edu.cn/#/problem/show/1265 题意 平面上给n个点(n<=1000),要求找一个面积最小的正方形,将所有的点都囊括 ...
- 第 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 ...
- 第六届福建省大学生程序设计竞赛(FZU2213—FZU2221)
from:piaocoder Common Tangents(两圆之间的公公切线) 题目链接: http://acm.fzu.edu.cn/problem.php?pid=2213 解题思路: 告诉你 ...
- UESTC-第五届ACM趣味程序设计竞赛第四场(正式赛)--不完全解题报告
比赛链接: http://acm.uestc.edu.cn/contest.php?cid=230 A.Police And The Thief ---UESTC 1913 简单博弈,先假设在警察先走 ...
- ZOJ 4100 浙江省第16届大学生程序设计竞赛 A题 Vertices in the Pocket 线段树+并查集
正赛的时候完全没看这个题,事后winterzz告诉我他想出来的解法. 首先题意是给出n个点,m次操作. 操作有一种是连接两个点,另一种是求此时再为这个图连k条边,最少和最多能有几个联通块. 最少的求法 ...
- ZOJ 4103 浙江省第16届大学生程序设计竞赛 D题 Traveler 构造
这个题,正赛的时候也没有过,不过其实已经有了正确的解法,可惜时间不多了,就没有去尝试. 题意是有n个点,i点能通向i-1,然后i和i*2.i*2+1互通. 请你构造一种路径从1能走完所有点,并且不重复 ...
- “浪潮杯”第九届山东省ACM大学生程序设计竞赛重现赛 C-Cities
题目描述:There are n cities in Byteland, and the ith city has a value ai. The cost of building a bidirec ...
- FZU - 2295 Human life:网络流-最大权闭合子图-二进制优化-第九届福建省大学生程序设计竞赛
目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 http://acm.fzu.edu.cn/problem.php?pid=2295 htt ...
随机推荐
- 【CodeForces727E/CF727E】Games on a CD (字符串哈希)
题目: CodeForces727E 分析: 看到字符串比较,肯定想到哈希啊--现学的哈希,先丢两个重要的公式 (\(seed\)是大于字符集大小的质数,\(p\)是大质数) \[hash[i]=(h ...
- unity多语言本地化
简介 嗯...一般来说做游戏啥的都不会只发一个国家,但是每个国家语言不同,就存在多语言本地化的问题,然后直接用过一个通过xml完成本地化的东东,然后策划反馈不会修改xml,扔给我一个excel让我自己 ...
- [ NOIP 1998 ] TG
\(\\\) \(\#A\) 车站 火车从第\(1\)站开出,上车的人数为\(a\),然后到达第\(2\)站,在第\(2\)站有人上.下车,但上.下车的人数相同,因此在第\(2\)站开出时(即在到达第 ...
- Python--10、进程知识补充
守护进程 基于进程启动的子进程,会和主进程一起结束.主进程结束的依据是程序的代码执行完毕. #创建守护进程p=Process(task) p.daemon = True p.start() 子进程需要 ...
- 解决:efi usb device has been blocked by the current security policy
解决:efi usb device has been blocked by the current security policy 问题描述:U盘装系统或者其他操作时,是因为BIOS安全策略,出现上述 ...
- 【年终糖果计划】跟风领一波糖果 candy.one 领取教程
糖果领取网址(较为稳定):https://candy.one/i/1474564 用微信和QQ打开的朋友请复制到其他浏览器打开 糖果领取网址(较为稳定):https://candy.one/i/147 ...
- Singleton.java.ft not found 相关错误的解决办法
Entry fileTemplates//Singleton.java.ft not found in C:/Users/admin/Desktop/android-studio/lib/resour ...
- 解决Android弹出软键盘导致的问题
一.当Activity启动后EditText直接获取了焦点,此时软键盘会自动弹出,这种体验并不是很好,因此要做的Activity启动不自动弹出软键盘,只需要在Manifest中对应的Activity添 ...
- 基于openstack平台的几种Cloud DB解决方案
方案一.openstack 官方 trove解决方案 此方案进行过镜像的打包,由于网络问题,还未能成功实现 方案二.salt 或者ansible+ docker 由于 docker部署数据库,在数据库 ...
- Java中内部类详解—匿名内部类
什么是内部类? 将一个类A定义在另一个类B里面,里面的那个类A就称为内部类,B则称为外部类. 成员内部类 定义在类中方法外的类. 定义格式: class 外部类 { class 内部类{ } } ...