ural 2021 Scarily interesting!(贪心)
2021. Scarily interesting!
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
5 |
5 1 |
Problem Source: NEERC 2014, Eastern subregional contest
All submissions (1925) All accepted submissions (506) Solutions rating (362)
#include <bits/stdc++.h>
using namespace std; const int MAXN = ; vector<int> vt1[];
vector<int> vt2[]; vector<int> vt3;
vector<int> vt4; int main()
{
int n;
int i;
int a, b;
vector<int>::iterator it1, it2;
int sum1, sum2; while (~scanf("%d", &n)) {
for (i = ; i <= ; ++i) {
vt1[i].clear();
vt2[i].clear();
}
vt3.clear();
vt4.clear();
sum1 = ;
sum2 = ;
for (i = ; i <= n; ++i) {
scanf("%d", &a);
vt1[a].push_back(i);
sum1 += a;
}
for (i = ; i <= n; ++i) {
scanf("%d", &b);
vt2[b].push_back(i);
sum2 += b;
}
// printf("debug 1\n");
for (i = ; i <= ; ++i) {
it1 = vt1[i].begin();
it2 = vt2[i].begin();
if (vt1[i].size() < vt2[i].size()) {
while (it1 < vt1[i].end()) {
printf("%d %d\n", *it1++, *it2++);
}
while (it2 < vt2[i].end()) {
vt4.push_back(*it2++);
}
} else {
// printf("debug 3\n");
while (it2 < vt2[i].end()) {
printf("%d %d\n", *it1++, *it2++);
}
while (it1 < vt1[i].end()) {
vt3.push_back(*it1++);
}
}
}
// printf("debug 2\n"); if (sum1 > sum2) {
it1 = vt3.begin();
it2 = vt4.end() - ;
while (it1 < vt3.end()) {
printf("%d %d\n", *it1++, *it2--);
}
} else {
it1 = vt3.end() - ;
it2 = vt4.begin();
while (it2 < vt4.end()) {
printf("%d %d\n", *it1--, *it2++);
}
} } return ;
}
ps:自己没想到这样做啊,
我的思路是让双方的分差越小越好,但是不知道这样做对不,写起来也比较复杂。
ural 2021 Scarily interesting!(贪心)的更多相关文章
- URAL 2021 Scarily interesting! (贪心+题意)
题意:给定两个队伍的每个人的得分,让你安排怎么比赛才能使得观众知道冠军的时间最长. 析:贪心,很简单,就是先开始总分高的先出最差劲的,总分低的先出最厉害的,这个题当时实在是读的不明白啊,WA了好多次. ...
- 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 1303 Minimal Coverage(贪心)
链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 按照贪心的思想,每次找到覆盖要求区间左端点时,右端点最大的线段,然后把要求覆盖的区间 ...
- URAL 1995 Illegal spices 贪心构造
Illegal spices 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1995 Description Jabba: Han, m ...
- 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 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...
- Contest 7.21(贪心专练)
这一次都主要是贪心练习 练习地址http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#overview Problem APOJ 13 ...
随机推荐
- python面试题(三)
1 一行代码实现9*9乘法表 print ("\n".join("\t".join(["%s*%s=%s" %(x,y,x*y) for y ...
- 从SignalTap II中获取“最真实”的仿真测试向量(ZZ)
在实际工作中,经常会遇到这样的情况:在硬件调试中采用SignalTap II反复多次编译并最终捕获到问题的原因时,才会发现,原来这个问题是逻辑问题,是可以在仿真环境下发现并快速解决的.先前没 ...
- More about Parameter Passing in Python(Mainly about list)
我之前写了一篇关于Python参数传递(http://www.cnblogs.com/lxw0109/p/python_parameter_passing.html)的博客, 写完之后,我发现我在使用 ...
- iOS Swift 熊猫🐼跑酷 第一个小项目
前言:想用swift 写个小游戏 慢慢转化 能写出 ARKit来.但是又不能一口吃个胖子,慢慢来,在网络视频教程中撸了视频教学,断断续续看了半个多月,基本实现了 游戏主角
- iOS UIScrollView 滚动到当前展示的视图居中展示
需求展示: 测试效果1 first uiscrollView 宽度 为屏幕宽度 滚动步长 为 scroll 宽度的1/3 分析: 这个是最普通版 无法使每一次滚动的结果子视图居中展示, WA ...
- Python学习进程(11)日期和时间
本节介绍Python应用程序处理时间和日期的方式.其中转换日期格式是最常用的功能. (1)获取时间戳: Python 提供了一个 time 和 calendar 模块可以用于格式化日期 ...
- vagrant搭建
1.在官网下载对应的vagrant版本 https://www.vagrantup.com/downloads.html (下载最新版本) https://releases.hashicorp.com ...
- Android Opencv NativeCameraView error in 5.0 lollipop versions (Bug #4185)
https://github.com/opencv/opencv/wiki http://code.opencv.org/issues/4185 Hello, I finally get a ride ...
- Django 路由、模板和模型系统
一.路由系统 URL配置(URLconf)就像Django 所支撑网站的目录.它的本质是URL模式以及要为该URL模式调用的视图函数之间的映射表:你就是以这种方式告诉Django,对于这个URL调用这 ...
- js怎么将光标移动特定的位置:
第一种方法: a 标签的锚: 将a标签的herf='#element_id_name' 即可 <a href="#comment_content" class=" ...