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 ...
随机推荐
- 虚拟化_KVM
一.KVM介绍 1.KVM全称kernel vitual machine,是针对包含虚拟化扩展(InterVT或AMD-V)的x86硬件上的完全原生的虚拟化解决方案 2.KVM是以色列Qumranet ...
- php文件删除
<?php $dirname="shangchuan/uploads"; deldir($dirname); function deldir($dirname){ if(fi ...
- 越狱Season 1-Episode 11: And Then There Were 7-M
Season 1, Episode 11: And Then There Were 7-M -Michael: That one 那个 -businessman: Nice choice choice ...
- Linux系统编程@文件操作(一)
只总结了部分常用的内容,详细内容参考<UNIX环境高级编程>及相关书籍. Linux中文件编程可以使用两种方法 Linux系统调用(依赖于系统) C语言库函数(不依赖于系统) Linux系 ...
- 简单工厂模式(Simple Factory Pattern)
简单工厂模式是属于创建型模式,又叫做静态工厂方法(Static Factory Method)模式,但不属于23种GOF设计模式之一.简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例.简单工厂 ...
- (转)Monte Carlo method 蒙特卡洛方法
转载自:维基百科 蒙特卡洛方法 https://zh.wikipedia.org/wiki/%E8%92%99%E5%9C%B0%E5%8D%A1%E7%BE%85%E6%96%B9%E6%B3%9 ...
- MAVEN build ,GOAL plugin ,execution
http://www.avajava.com/tutorials/lessons/what-are-the-phases-of-the-maven-clean-lifecycle.html https ...
- android语言适配
虽然我们现在做的app基本只在国内使用,所以只需要中文,但是我们要把眼光放长远一点,以后我们的APP发展到了国外呢,所以我们就要做语言适配了 很简单 在res目录下,右键 New Resourc ...
- Web前端开发笔试&面试_05
>>CW 1.JavaScript的2种变量范围有什么不同? 2.JavaScript 的对象有哪些? 3.
- Undefined symbols for architecture i386: "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)"
今天把apple developer上的例子程序oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c添加到自己的工程中,并在另一个文件xxx.cpp里调用,结果出 ...