hdu 4907 Task schedule
来源:互联网 发布:cnc数控机床编程 编辑:程序博客网 时间:2024/05/17 09:06
hdu 4907 Task schedule
工厂进行生产工作 有机器进行工作 有个生产任务的时间表 一秒钟完成一个任务
在完成任务的同时可能会产生新的任务 在机器空闲的时候将之前产生的多余的任务完成
我初始的想法是 从任务安排表中找出时间安排的空隙 保存 然后读取附加任务的时间 与任务表中最小的以及保存的空隙进行大小比较 感觉思路没什么问题 有可能是给的数据不是按大小排列的
感觉别人都是做的蛮快的 自己写了好久就是WA 唉。。
思路呢 也是蛮简单的 将任务表中出现过的数 在数组相应的位置标记为1
然后去读取用now保存当前能去完成多余任务的时间 代码一看就懂了。。。这种题目还是要多积累
#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <string.h>#include <string>#define eps 1e-8#define op operator#define MOD 10009#define MAXN 200005using namespace std;int a[MAXN];int q[MAXN];int main(){//freopen("ceshi.txt","r",stdin); int tc; scanf("%d",&tc); while(tc--) { int n,m; scanf("%d%d",&n,&m); memset(a,0,sizeof a); memset(q,0,sizeof q); for(int i=0;i<n;i++) { int temp; scanf("%d",&temp); a[temp]=1; } int now=200001; for(int i=200001;i>=1;i--) { if(!a[i]) now=i; q[i]=now; } for(int i=0;i<m;i++) { int temp; scanf("%d",&temp); printf("%d\n",q[temp]); } } return 0;}
0 0
- HDU 4907 Task schedule
- hdu 4907 Task schedule
- hdu 4907 Task schedule
- HDU 4907 Task schedule
- hdu 4907 Task schedule
- HDU 4907 Task schedule
- HDU-4907 Task schedule
- HDU 4907 Task schedule
- hdu 4907 Task schedule
- HDU-4907 Task schedule
- hdu 4907 Task schedule
- HDU 4907Task schedule
- HDU 4907 Task schedule
- HDU 4907-Task schedule
- hdu-4907-Task schedule
- hdu 4907 Task schedule
- HDU 4907 BestCoder3_1 Task schedule
- hdu 4907 Task schedule(水题)
- OpenSessionInViewFilter的作用
- HDU 4285 circuits[插头DP]
- POJ 2255 Tree Recovery
- Python多线程
- android TrafficStats 流量检测类
- hdu 4907 Task schedule
- hollister pas cher soldes saw someone singing
- Android高手的六大境界
- tn nike pas cher and they are the same age fellow worthy of their admiration
- ZOJ 3686-A Simple Tree Problem (DFS+线段树)
- hogan outlet 2014 All Rights Reserved
- 8.4 如何用JS写计算器
- ssh-keygen 免交互, ssh首次交互免输入yes
- hollister pas cher but Wang and Han Yan found that the kidnappers call not hit the Wang family.