Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健(37509)
- Result: MLE Submission_id: 4471349
- Created at: Fri May 20 2022 10:34:09 GMT+0800 (China Standard Time)
- Problem: 5840 Time: 314 Memory: 205780
- */
- /*
- Author: 曹北健(37509)
- Result: MLE Submission_id: 4471346
- Created at: Fri May 20 2022 10:32:43 GMT+0800 (China Standard Time)
- Problem: 5840 Time: 362 Memory: 206080
- */
- /*
- Author: 曹北健
- Result: AC Submission_id: 3487299
- Created at: Fri May 14 2021 09:02:29 GMT+0800 (China Standard Time)
- Problem_id: 4425 Time: 744 Memory: 204800
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <math.h>
- #include <string.h>
- #include <time.h>
- #include <assert.h>
- #pragma warning(disable:4996)
- typedef long long LL;
- typedef struct _data{
- int age,index;
- char name[1024];
- }data,*pdata;
- data arr[200010] = {0};
- pdata pt[200010] = {0};
- int compare(const void *p,const void *q){
- pdata a = *(pdata *)p,b = *(pdata *)q;
- if(a->age == b->age)return a->index - b->index;
- else return a->age - b->age;
- }
- int main(){
- #ifdef _DEBUG
- freopen("input.txt","r",stdin);
- #ifdef OFILE
- freopen("test2.txt","w",stdout);
- #endif
- #endif
- int n,m,t,i;
- scanf("%d%d",&n,&m);
- for(i = 0;i < n;i++){
- scanf("%d%s",&arr[i].age,arr[i].name);
- arr[i].index = i;pt[i] = arr + i;
- }
- qsort(pt,n,sizeof(pdata),compare);
- while(m--){
- scanf("%d",&t);
- printf("%d %s\n",pt[t - 1]->age,pt[t - 1]->name);
- }
- #ifdef _DEBUG
- freopen("CON","r",stdin);
- #ifdef OFILE
- freopen("CON","w",stdout);
- #endif
- system("pause");
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment