Codeforces Round #364 (Div. 2) Cards
Cards
题意:
给你n个牌,n是偶数,要你把这些牌分给n/2个人,并且让每个人的牌加起来相等。
题解:
这题我做的时候,最先想到的是模拟,之后码了一会,发现有些麻烦,就想别的方法。之后发现只要把它给的数排序就好了,排完序后输出原来的位置就好,因为每2个都能配对所以最小肯定配最大,第二小配第二大…… 之后就可以a了
代码:
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long ll;
#define PU puts("")
#define PI(A) printf("%d\n",A)
#define SI(N) scanf("%d",&(N))
#define SII(N,M) scanf("%d%d",&(N),&(M))
#define cle(a,val) memset(a,(val),sizeof(a))
#define rep(i,b) for(int i=0;i<(b);i++)
#define Rep(i,a,b) for(int i=(a);i<=(b);i++)
#define reRep(i,a,b) for(int i=(a);i>=(b);i--)
const double EPS= 1e-9 ;
/* ///////////////////////// C o d i n g S p a c e ///////////////////////// */
const int MAXN= 100 + 9 ;
struct NODE
{
int a,b;
bool operator <(const NODE n) const
{
return n.a<a;
}
};
NODE a[MAXN];
int N;
int main()
{
while(~SI(N))
{
Rep(i,1,N)
{
SI(a[i].a);
a[i].b=i;
}
sort(a+1,a+N+1);
for (int i=1;i<=N/2;i++)
{
printf("%d %d\n",a[i].b,a[N-i+1].b);
}
}
return 0;
}
Codeforces Round #364 (Div. 2) Cards的更多相关文章
- Codeforces Round #364 (Div. 2)->A. Cards
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #364 (Div. 2)
这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无 ...
- Codeforces Round #364 (Div.2) D:As Fast As Possible(模拟+推公式)
题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...
- Codeforces Round #364 (Div.2) C:They Are Everywhere(双指针/尺取法)
题目链接: http://codeforces.com/contest/701/problem/C 题意: 给出一个长度为n的字符串,要我们找出最小的子字符串包含所有的不同字符. 分析: 1.尺取法, ...
- 树形dp Codeforces Round #364 (Div. 1)B
http://codeforces.com/problemset/problem/700/B 题目大意:给你一棵树,给你k个树上的点对.找到k/2个点对,使它在树上的距离最远.问,最大距离是多少? 思 ...
- Codeforces Round #364 (Div. 2) A
Description There are n cards (n is even) in the deck. Each card has a positive integer written on i ...
- Codeforces Round #364 (Div. 2) A 水
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #364 (Div. 2),只有A与B
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #364 (Div. 2) B. Cells Not Under Attack
B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...
随机推荐
- Linux-eth0 eth0:1 和eth0.1关系、ifconfig以及虚拟IP实现介绍
eth0 eth0:1 和eth0.1三者的关系对应于物理网卡.子网卡.虚拟VLAN网卡的关系:物理网卡:物理网卡这里指的是服务器上实际的网络接口设备,这里我服务器上双网卡,在系统中看到的2个物理网卡 ...
- ABBYY如何把PDF转换Excel
我们都知道2007以上版本的Office文档,是可以直接将文档转存为PDF格式文档的.那么反过来,PDF文档可以转换成其他格式的文档吗?这是大家都比较好奇的话题.如果可以以其他格式进行保存,就可以极大 ...
- SQL Server 系统表简介
SQL Server 系统表简介 系统目录是由描述SQL Server 系统的数据库.基表.视图和索引等对象的结构的系统表组成.SQL Server 经常访问系统目录,检索系统正常运行所需的必要信息. ...
- 019. Asp.net将SqlServer中的数据保存到xls/txt中
using System; using System.Collections; using System.Configuration; using System.Data; using System. ...
- Java 笔试题集锦
1.Java 不需要使用构造函数来创建对象的方法有哪些? 2.Java 创建多线程有哪些方法?你最喜欢哪一个?为什么? 3.Java
- unity, 查看.anim中的动画曲线(和帧)
在场景里建一个gameObject,添加一个Animation组件,将.anim文件添加到Animation组件的Animations中,然后在Animation组件面板中选中.anim,然后 菜单- ...
- apache commons vfs 文件夹监控
package test.vfs; import java.io.File; import org.apache.commons.logging.Log; import org.apache.comm ...
- SpringMVC的各种参数绑定方式
1. 基本数据类型(以int为例,其他类似):2. 包装类型(以Integer为例,其他类似):3. 自定义对象类型:4. 自定义复合对象类型:5. List绑定:6. Set绑定:7. Map绑定: ...
- VLOOKUP 函数
如果需要在表格或区域中按行查找内容,可使用 VLOOKUP,它是一个查找和引用函数.例如,按部件号查找汽车部件的价格. =VLOOKUP(要查找的值.要在其中查找值的区域.区域中包含返回值的列号.精确 ...
- C#Winform中treeView控件使用总结
1.如何展开结点时改变图标(注意:不是选中时) 要在目录中使用图标首先要加入一个控件ImageList(命名为imageList1),然后可以按图片的index或名称引用图片. 然后需要在TreeVi ...