URAL 2021 Scarily interesting! (贪心+题意)
题意:给定两个队伍的每个人的得分,让你安排怎么比赛才能使得观众知道冠军的时间最长。
析:贪心,很简单,就是先开始总分高的先出最差劲的,总分低的先出最厉害的,这个题当时实在是读的不明白啊,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! (贪心+题意)的更多相关文章
- ural 2021 Scarily interesting!(贪心)
2021. Scarily interesting! Time limit: 1.0 secondMemory limit: 64 MB This year at Monsters Universit ...
- Gym 100507J Scarily interesting! (贪心)
Scarily interesting! 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Description This y ...
- J - Scarily interesting! URAL - 2021
This year at Monsters University it is decided to arrange Scare Games. At the Games all campus gathe ...
- Scarily interesting! (URAL - 2021)
Problem This year at Monsters University it is decided to arrange Scare Games. At the Games all camp ...
- URAL 1995 Illegal spices 贪心构造
Illegal spices 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1995 Description Jabba: Han, m ...
- ural 1303 Minimal Coverage(贪心)
链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 按照贪心的思想,每次找到覆盖要求区间左端点时,右端点最大的线段,然后把要求覆盖的区间 ...
- UVa 1612 Guess (贪心+题意)
题意:有 n 位选手参加编程比赛.比赛有3道题目,每个选手的每道题目都有一个评测之前的预得分(这个分数和选手提交程序的时间相关,提交的越早,预得分越大). 接下来 是系统评测.如果某道题未通过测试,则 ...
- Ural 2070:Interesting Numbers(思维)
http://acm.timus.ru/problem.aspx?space=1&num=2070 题意:A认为如果某个数为质数的话,该数字是有趣的.B认为如果某个数它分解得到的因子数目是素数 ...
- NEERC 2014, Eastern subregional contest
最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...
随机推荐
- 爬虫 spider
python 2.x # -*- coding: utf-8 -*-import reimport urllib url = 'http://tieba.baidu.com/p/4872795764' ...
- Windows默认字符集_查询
https://zhidao.baidu.com/question/32462047.html Windows95. XP……7操作系统自带的都是GBK字符集(含2万余汉字),是完全兼容GB2312( ...
- Linux - xshell上传文件报错乱码
xshell上传文件报错乱码,解决方法 rz -be 回车 下载sz filename
- matlab中的科学记数法变成小数形式
例如:假如rectx的形式在命令窗口显示: rectx = 1.0e+05 * 5.2294 5.2294 5.2294 5.2294 5.2294 那么,命令窗口输入vpa(rectx): ans ...
- WCF的宿主
接下来继续WCF(网上的方法)(实例) 1.无废话WCF入门教程一与无废话WCF入门教程二(http://www.cnblogs.com/iamlilinfeng/archive/2012/09/25 ...
- vue2.0使用Sortable.js实现的拖拽功能
简介 在使用vue1.x之前的版本的时候,页面中的拖拽功能,我在项目中是直接用的jQuery ui中的sortable.js,只是在拖拽完成后,在update的回调函数中又重新排序了存放数据的数组.但 ...
- Centos7搭建Mysql-5.6.38,及主从复制。
Server1:192.168.1.189 (主) Server2:192.168.1.190 (从) 1.关闭默认的firewalld防火墙,安装iptables. systemctl disa ...
- JavaUtil_06_HttpUtil_使用httpclient实现
一.简介 使用 appache 的 httpclient 来实现的 二.源码 package com.ray.weixin.gz.util; import java.io.File; import j ...
- Vue从接口请求数据
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...
- Json解析方式
http://blog.sina.com.cn/s/blog_628cc2b70101dydc.html