标签:style blog http color os io for art
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4907
代码:
1 #include <algorithm> 2 #include <iostream> 3 #include <sstream> 4 #include <cstdlib> 5 #include <cstring> 6 #include <cstdio> 7 #include <string> 8 #include <bitset> 9 #include <vector> 10 #include <queue> 11 #include <stack> 12 #include <cmath> 13 #include <list> 14 //#include <map> 15 #include <set> 16 using namespace std; 17 /***************************************/ 18 #define ll long long 19 #define int64 __int64 20 #define PI 3.1415927 21 /***************************************/ 22 const int INF = 0x7f7f7f7f; 23 const double eps = 1e-8; 24 const double PIE=acos(-1.0); 25 const int d1x[]= {0,-1,0,1}; 26 const int d1y[]= {-1,0,1,0}; 27 const int d2x[]= {0,-1,0,1}; 28 const int d2y[]= {1,0,-1,0}; 29 const int fx[]= {-1,-1,-1,0,0,1,1,1}; 30 const int fy[]= {-1,0,1,-1,1,-1,0,1}; 31 const int dirx[]= {-1,1,-2,2,-2,2,-1,1}; 32 const int diry[]= {-2,-2,-1,-1,1,1,2,2}; 33 /*vector <int>map[N];map[a].push_back(b);int len=map[v].size();*/ 34 /***************************************/ 35 void openfile() 36 { 37 freopen("data.in","rb",stdin); 38 freopen("data.out","wb",stdout); 39 } 40 priority_queue<int> qi1; 41 priority_queue<int, vector<int>, greater<int> >qi2; 42 /**********************华丽丽的分割线,以上为模板部分*****************/ 43 const int M=100005; 44 int a[2*M],b[2*M]; 45 int main() 46 { 47 int cas; 48 scanf("%d",&cas); 49 while(cas--) 50 { 51 int n,q; 52 scanf("%d",&n); 53 scanf("%d",&q); 54 int x; 55 memset(a,0,sizeof(a)); 56 memset(b,0,sizeof(b)); 57 for(int i=0;i<n;i++) 58 { 59 scanf("%d",&x); 60 a[x]=1; 61 } 62 int k=1; 63 for(int i=2*M;i>0;i--) 64 { 65 if (a[i]==1) 66 { 67 b[i]=b[i+1]; 68 continue; 69 } 70 b[i]=i; 71 } 72 while(q--) 73 { 74 scanf("%d",&x); 75 printf("%d\n",b[x]); 76 } 77 } 78 return 0; 79 }
BestCoder Round #3(A),布布扣,bubuko.com
标签:style blog http color os io for art
原文地址:http://www.cnblogs.com/ZhaoPengkinghold/p/3889382.html