标签:des style http color java os io strong
原题http://acm.hdu.edu.cn/showproblem.php?pid=4907
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 692 Accepted Submission(s): 334
1 5 5 1 2 3 5 6 1 2 3 4 5
4 4 4 4 7
//本题要是直接做会超时,所以採用预处理的方法。听说二分也能够,只是没有试过,感觉预处理已经挺快的了 //思路,开个数组,代表在i秒进行额外工作的时间。非常明显,在预处理的时候要从后往前找 //假设该时间该机器本身不须要工作,那么就吧时间不断的缩小 include <stdio.h> #include <stdlib.h> #include <malloc.h> #include <limits.h> #include <string.h> #include <string> #include <math.h> #include <algorithm> #include <iostream> #include <stack> #include <queue> #include <deque> #include <vector> #include <set> #include <map> using namespace std; #define N 100000 + 10 #define M 200000 + 10 int vis[M]; int take[M]; int main(){ int T,n,m; while(~scanf("%d",&T)){ while(T--){ memset(vis,0,sizeof(vis)); memset(take,0,sizeof(take)); scanf("%d%d",&n,&m); int i,num; for(i=1;i<=n;i++){ scanf("%d",&num); vis[num] = 1; } int mark; for(i=200000;i>=1;i--){ take[i] = i; if(vis[i] == 0){ mark = i; } else{ take[i] = mark; } } int t; for(i=1;i<=m;i++){ scanf("%d",&t); printf("%d\n",take[t]); } } } return 0; }
标签:des style http color java os io strong
原文地址:http://www.cnblogs.com/yxwkf/p/3899776.html