CodeForces
来源:互联网 发布:淘宝网的营销模式是 编辑:程序博客网 时间:2024/06/06 21:01
本题在比赛的时候也是想不出啊,随便贪了一下果然没用,然后也没有尝试了.
是一个很妙的贪心啊,这题是d也不是没有理由.
大概办法就是对a的序号排序(根据对应元素大小),然后分奇偶讨论,主体就是每组两个来考虑,选b中大的那个,然后处理下头就行了
/* xzppp */#include <iostream>#include <vector>#include <set>#include <queue>#include <map>#include <algorithm>#include <stdio.h>#include <string.h>#include <list>using namespace std;#define FFF freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define mp make_pairconst int MAXN = 100000;const int INF = 0x7ffffff;const int MOD = 1e9+7;typedef long long LL;typedef unsigned long long ULL;int a[MAXN+17],b[MAXN+17],id[MAXN+17];inline bool cmp(int c,int d){ return a[c-1]>a[d-1];}int main(){ //FFF int n; cin>>n; for (int i = 0; i < n; ++i) scanf("%d",a+i); for (int i = 0; i < n; ++i) scanf("%d",b+i); for (int i = 0; i < n; ++i) id[i]=i+1; sort(id, id+n,cmp); printf("%d\n",n/2+1 ); printf("%d\n",id[0] ); if(!(n&1)) printf("%d\n",id[1]); int t = (n&1)?n/2:n/2-1,j; for (j=n-1; t > 0; t--,j-=2) printf("%d\n",(b[id[j]-1]>b[id[j-1]-1]?id[j]:id[j-1])); return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 火车进站问题
- mustache template
- Zynq-Linux移植学习笔记之14-RapidIO驱动开发
- 容器的概念
- LINUX之用户态和内核态区别
- CodeForces
- java基础复习--复习总结10
- web项目Log4j日志输出路径配置问题
- URI和URL的区别
- Linux-常用命令记录表
- JSON数组的构造
- DevExpress GridControl的使用,DevExpress.XtraGrid.Views.Grid.GridView使用
- Linux NTP服务器配置
- Neo4j初探