【Codeforces Round #429 (Div. 2) C】Leha and Function
【Link】:http://codeforces.com/contest/841/problem/C
【Description】
【Solution】
看到最大的和最小的对应,第二大的和第二小的对应。
贪心,排个序。
【NumberOf WA】
【Reviw】
【Code】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 2e5;
struct abc{
int x,id;
};
abc a[N+10],b[N+10];
int m,ans[N+10];
bool cmp1(abc a,abc b){
return a.x > b.x;
}
bool cmp2(abc a,abc b){
return a.x < b.x;
}
int main(){
//Open();
//Close();
ri(m);
rep1(i,1,m){
ri(a[i].x);
a[i].id = i;
}
rep1(i,1,m){
ri(b[i].x);
b[i].id = i;
}
sort(a+1,a+1+m,cmp1);
sort(b+1,b+1+m,cmp2);
rep1(i,1,m){
ans[b[i].id] = a[i].x;
}
rep1(i,1,m){
oi(ans[i]);
if (i==m)
puts("");
else
oc;
}
return 0;
}
【Codeforces Round #429 (Div. 2) C】Leha and Function的更多相关文章
- 【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 ...
- 【Codeforces Round #429 (Div. 2) A】Generous Kefa
[Link]:http://codeforces.com/contest/841/problem/A [Description] [Solution] 模拟,贪心,每个朋友尽量地多给气球. [Numb ...
- 【Codeforces Round #429 (Div. 2) B】 Godsend
[Link]:http://codeforces.com/contest/841/problem/B [Description] 两个人轮流对一个数组玩游戏,第一个人可以把连续的一段为奇数的拿走,第二 ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
- 【Codeforces Round #423 (Div. 2) C】String Reconstruction
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
- 【Codeforces Round #423 (Div. 2) B】Black Square
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
随机推荐
- 【leetcode】395. Longest Substring with At Least K Repeating Characters
题目如下: 解题思路:题目要找出一段连续的子串内所有字符出现的次数必须要大于k,因此出现次数小于k的字符就一定不能出现,所以就可以以这些字符作为分隔符分割成多个子串,然后继续对子串递归,找出符合条件的 ...
- 【leetcode】922. Sort Array By Parity II
题目如下: 解题思路:非常简单的题目,引入两个变量oddInx = 1和evenInx = 0,和与A等长的结果数组res.然后遍历A,如果A[i]为偶数,则令res[evenInx] = A[i], ...
- 学习java web中的listener
web.xml里的顺序为:context-param->listener->filter->servlet 监听器是需要新建一个类,然后按监听的对象继承:ServletContext ...
- Django实现得步骤流程
我们利用django实现功能得时候,步骤和流程是怎样得呢? 一,首先要在Models中创建表. 1,在setting中找到DATABASE 中找到要使用得数据库,用mysql就把名字改了mysql. ...
- 100万DAU的app技术架构(简单理解)
如图所示:
- SQL之in和like的连用实现范围内的模糊查询
我们知道in可以实现一个范围内的查询,like可以实现模糊查询, 如 select *where col like 123%但是我们如果有一列attri,如123,132,165... 我们想实现12 ...
- mysql分表分库 ,读写分离
1.分表 当项目上线后,数据将会几何级的增长,当数据很多的时候,读取性能将会下降,更新表数据的时候也需要更新索引,所以我们需要分表,当数据量再大的时候就需要分库了. a.水平拆分:数据分成多个表 b. ...
- activiti7业务表示Businesskey
启动流程实例时,指定的businesskey,就会在act_ru_execution #流程实例的执行表中存储businesskey. Businesskey:业务标识,通常为业务表的主键,业务标识和 ...
- UVA11988_Broken Keyboard (a.k.a. Beiju Text)
即将dfs()放到打印本段字符的后面 不过汝佳书上面说是用链表写的,无意中用递归写出来了,而且写的挺简单的,代码不复杂,写这个博客主要是想记住递归这种神奇的方法 平时递归搜索时候,dfs()的在其他代 ...
- python 自带http服务
python2: python -m SimpleHTTPServer python3: python3 -m http.server