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 ...
随机推荐
- Docker安装及基本使用方法
Docker安装 CentOS6上安装Docker # yum -y install epel-release # yum -y install docker-io CentOS7上安装Docker ...
- LeetCode() Search a 2D MatrixII
一开始的超时思路 int row=a.size(),col=a[0].size(); for(int i=0;i<row;i++) { if(a[i][col-1] > target &a ...
- hdu4725 拆点+最短路
题意:有 n 个点,每个点有它所在的层数,最多有 n 层,相邻两层之间的点可以互相到达,消耗 c (但同一层并不能直接到达),然后还有一些额外的路径,可以在两点间互相到达,并且消耗一定费用.问 1 点 ...
- 《苹果开发之Cocoa编程》挑战2 创建一个数据源 练习
<苹果开发之Cocoa编程>第4版 P87 创建一个to-do list应用程序,在文本框中输入任务.当用户单击Add按钮时,添加字符串到一个变长队列,新任务就出现在list的末尾. 关键 ...
- spring beans源码解读之--Bean的注解(annotation)
随着spring注解的引入,越来越多的开发者开始使用注解,这篇文章将对注解的机制进行串联式的讲解,不求深入透彻,但求串起spring beans注解的珍珠,展示给大家. 1. spring beans ...
- C++面向对象要点
先说说面向对象思想的一个总体认识 对象通常会有行为,这些行为是靠信息支撑,这些信息包括外部信息和内部信息,对象行为会维护其中的一部分信息 因此对象可以看成是这样一种实体,它获取信息,然后决定自己的行为 ...
- Verilog
1.位拼接运算符{}
- gcviewer待整理
官网:https://github.com/chewiebug/GCViewer G1 Gabage Collector -XX:+UnlockExperimentalVMOptions -XX:+U ...
- JavaScript的事件绑定及深入
事件绑定分为两种:一种是传统事件绑定(内联模型,脚本模型),一种是现代事件绑定 (DOM2 级模型).现代事件绑定在传统绑定上提供了更强大更方便的功能. 一.传统事件绑定的问题传统事件绑定有内联模型 ...
- Spring3.1新属性管理API:PropertySource、Environment、Profile
Spring3.1提供了新的属性管理API,而且功能非常强大且很完善,对于一些属性配置信息都应该使用新的API来管理.虽然现在Spring已经到4版本了,这篇文章来的晚点. 新的属性管理API Pro ...