【Link】:http://codeforces.com/contest/841/problem/C

【Description】

【Solution】



看到最大的和最小的对应,第二大的和第二小的对应。

贪心,排个序。



【NumberOf WA】

【Reviw】

【Code】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,m,rt<<1
  4. #define rson m+1,r,rt<<1|1
  5. #define LL long long
  6. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  7. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  8. #define mp make_pair
  9. #define pb push_back
  10. #define fi first
  11. #define se second
  12. #define ms(x,y) memset(x,y,sizeof x)
  13. #define ri(x) scanf("%d",&x)
  14. #define rl(x) scanf("%lld",&x)
  15. #define rs(x) scanf("%s",x+1)
  16. #define oi(x) printf("%d",x)
  17. #define ol(x) printf("%lld",x)
  18. #define oc putchar(' ')
  19. #define os(x) printf(x)
  20. #define all(x) x.begin(),x.end()
  21. #define Open() freopen("F:\\rush.txt","r",stdin)
  22. #define Close() ios::sync_with_stdio(0)
  23. typedef pair<int,int> pii;
  24. typedef pair<LL,LL> pll;
  25. const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
  26. const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
  27. const double pi = acos(-1.0);
  28. const int N = 2e5;
  29. struct abc{
  30. int x,id;
  31. };
  32. abc a[N+10],b[N+10];
  33. int m,ans[N+10];
  34. bool cmp1(abc a,abc b){
  35. return a.x > b.x;
  36. }
  37. bool cmp2(abc a,abc b){
  38. return a.x < b.x;
  39. }
  40. int main(){
  41. //Open();
  42. //Close();
  43. ri(m);
  44. rep1(i,1,m){
  45. ri(a[i].x);
  46. a[i].id = i;
  47. }
  48. rep1(i,1,m){
  49. ri(b[i].x);
  50. b[i].id = i;
  51. }
  52. sort(a+1,a+1+m,cmp1);
  53. sort(b+1,b+1+m,cmp2);
  54. rep1(i,1,m){
  55. ans[b[i].id] = a[i].x;
  56. }
  57. rep1(i,1,m){
  58. oi(ans[i]);
  59. if (i==m)
  60. puts("");
  61. else
  62. oc;
  63. }
  64. return 0;
  65. }

【Codeforces Round #429 (Div. 2) C】Leha and Function的更多相关文章

  1. 【Codeforces Round #429 (Div. 1) B】Leha and another game about graph

    [链接]点击打开链接 [题意] 给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么  dgree[i] % 2 == d[i],dgr ...

  2. 【Codeforces Round #429 (Div. 2) A】Generous Kefa

    [Link]:http://codeforces.com/contest/841/problem/A [Description] [Solution] 模拟,贪心,每个朋友尽量地多给气球. [Numb ...

  3. 【Codeforces Round #429 (Div. 2) B】 Godsend

    [Link]:http://codeforces.com/contest/841/problem/B [Description] 两个人轮流对一个数组玩游戏,第一个人可以把连续的一段为奇数的拿走,第二 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  6. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  7. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

随机推荐

  1. spring无法接收上传文件

    现象 前端用ajax方式提交表单,代码类似于下面的例子. var formData = new FormData(); // HTML 文件类型input,由用户选择 formData.append( ...

  2. php wordwrap()函数 语法

    php wordwrap()函数 语法 wordwrap()函数怎么用? wordwrap()函数表示按照指定长度对字符串进行折行处理,语法是wordwrap(string,width,break,c ...

  3. Android 模糊搜索rawquery bind or column index out of range: handle 0x2fb180 报错

    做模糊搜索时,出现了  bind or column index out of range: handle 0x2fb180 报错 public Cursor getTitle(String word ...

  4. Python基础教程(012)--排查手误错误

    前言 排查由于手误书写错误的方法 内容 手动输入错误的时候,颜色是红色 函数名称写错 1,颜色不一样 2,nameError错误 掌握知识点 学会在写代码的时候排查错误

  5. 微信公众号的SpringBoot+Quartz的定时任务Demo

    SpringBoot整合quartz并不难,难在普通类实现了Job接口后等于实例化交给quartz,不受Spring管理,则service层等等其他依赖的注入将无法注入,这也是难点之一. 解决方法: ...

  6. kafka ConsumerConfig 配置

  7. 个人笔记 - C++相关收藏

    一.文件操作 1.C++从txt文件中读取二维的数组

  8. JSHOP2

    JSHOP2是一个HTN(hierarchy task network)规划器,是SHOP2(simple hierarchy ordered planner )的java实现版本. SHOP2的官网 ...

  9. eclipse中选取一列快捷键

    eclipse中选取一列 比如选中下面的1 4 1   2   3 4   5   6 快捷键 alt+shift+拖动鼠标

  10. ES6数组方法

    ES6数组方法 以下方法添加到了Array.prototype对象上(isArray除外) indexOf 类似字符串的indexOf()方法 stringObject.indexOf(searchv ...