题意:给定两个队伍的每个人的得分,让你安排怎么比赛才能使得观众知道冠军的时间最长。

析:贪心,很简单,就是先开始总分高的先出最差劲的,总分低的先出最厉害的,这个题当时实在是读的不明白啊,WA了好多次。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e16;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} struct Node{
int id, val;
bool operator < (const Node &p) const{
return val < p.val;
}
};
vector<Node> v1, v2; int main(){
cin >> n;
int sum1 = 0, sum2 = 0;
for(int i = 1; i <= n; ++i){
scanf("%d", &m);
v1.push_back((Node){i, m});
sum1 += m;
}
for(int i = 1; i <= n; ++i){
scanf("%d", &m);
v2.push_back((Node){i, m});
sum2 += m;
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
if(sum1 > sum2) for(int i = 0; i < n; ++i) printf("%d %d\n", v1[i].id, v2[n-i-1].id);
else for(int i = 0; i < n; ++i) printf("%d %d\n", v1[n-i-1].id, v2[i].id); return 0;
}

  

URAL 2021 Scarily interesting! (贪心+题意)的更多相关文章

  1. ural 2021 Scarily interesting!(贪心)

    2021. Scarily interesting! Time limit: 1.0 secondMemory limit: 64 MB This year at Monsters Universit ...

  2. Gym 100507J Scarily interesting! (贪心)

    Scarily interesting! 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Description This y ...

  3. J - Scarily interesting! URAL - 2021

    This year at Monsters University it is decided to arrange Scare Games. At the Games all campus gathe ...

  4. Scarily interesting! (URAL - 2021)

    Problem This year at Monsters University it is decided to arrange Scare Games. At the Games all camp ...

  5. URAL 1995 Illegal spices 贪心构造

    Illegal spices 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1995 Description Jabba: Han, m ...

  6. ural 1303 Minimal Coverage(贪心)

    链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 按照贪心的思想,每次找到覆盖要求区间左端点时,右端点最大的线段,然后把要求覆盖的区间 ...

  7. UVa 1612 Guess (贪心+题意)

    题意:有 n 位选手参加编程比赛.比赛有3道题目,每个选手的每道题目都有一个评测之前的预得分(这个分数和选手提交程序的时间相关,提交的越早,预得分越大). 接下来 是系统评测.如果某道题未通过测试,则 ...

  8. Ural 2070:Interesting Numbers(思维)

    http://acm.timus.ru/problem.aspx?space=1&num=2070 题意:A认为如果某个数为质数的话,该数字是有趣的.B认为如果某个数它分解得到的因子数目是素数 ...

  9. NEERC 2014, Eastern subregional contest

    最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...

随机推荐

  1. Docker 数据管理-Volumes

    Volumes是Docker最为推荐的数据持久化方法. Volumes have several advantages over bind mounts: Volumes are easier to ...

  2. 命令行 -- 命令"%cd%"

    1. @echo off echo 当前盘符:%~d0 echo 当前盘符和路径:%~dp0 echo 当前批处理全路径:%~f0 echo 当前盘符和路径的短文件名格式:%~sdp0 echo 当前 ...

  3. HDU 4089 Activation:概率dp + 迭代【手动消元】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4089 题意: 有n个人在排队激活游戏,Tomato排在第m个. 每次队列中的第一个人去激活游戏,有可能 ...

  4. mvc购物车项目

    第一个mvc项目--购物车. 1.购物车需求 a.用户可以登录 b.用户可以购买商品 c.用户可以对购物车的商品进行修改和删除 d.用户可以下订单 e.系统可以发送电子邮件给用户 uml图 2.界面设 ...

  5. 英语发音规则---J字母

    英语发音规则---J字母 一.总结 一句话总结: j只发[dʒ]音:jeep [dʒiːp] n. :jail [dʒeɪl] n. jeep [dʒiːp] n. 吉普车 jar [dʒɑː] n. ...

  6. django 使用内建过滤器实现文章摘要效果

    django 使用内建过滤器实现文章摘要效果 前端html代码 <div class="list-group"> {% if articles %} {% for ar ...

  7. 分享知识-快乐自己:Liunx 安装 Zookeeper

    Zookeeper可以安装在windows中也可以安装在linux中! 但是我们的服务器基本都是在linux之上 安装我们的 zookeeper 注册中心! 安装成功之后  修改 nat 模式对应的端 ...

  8. python习题-产生8位随机密码要包含大小写及数字

    # 1.写一个产生密码的程序,# 输入次数,输入多少次就产生多少条数据,# 要求密码必须包含大写字母.小写字母和数字,长度8位,不能重复 #需求分析#1.循环,输入什么就循环多少次#2.随机来取值,是 ...

  9. hdu-5861 Road(并查集)

    题目链接: Road Time Limit: 12000/6000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Pro ...

  10. OpenCV - Android Studio 中集成Opencv环境(包含opencv_contrib部分)

    我在上一篇博客中说到了在Android中集成OpenCV,但是那个版本的OpenCV是没有SIFT和SURF算法的,因为这些算法是受专利保护的,所以并没有被包含在预编译库中,所以如果想要使用SIFT和 ...