【2017 Multi-University Training Contest - Team 10】Schedule
【链接】http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1010&cid=767
【题意】
【题解】
【错的次数】
【反思】
【代码】
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 1e5; multiset <int> myset;
pii a[N + 10];
int n;
LL ans = 0; int main() {
//Open();
//Close();
int T;
ri(T);
while (T--) {
ri(n);
rep1(i, 1, n)
ri(a[i].fi), ri(a[i].se);
sort(a + 1, a + 1 + n);
myset.clear();
LL ans = 0;
rep1(i, 1, n) {
auto temp = myset.upper_bound(a[i].fi);
//cout <<"i="<<i<<' ';cout << (*temp) << endl;
if (temp == myset.begin()) {
myset.insert(a[i].se);
ans = (ans + a[i].second - a[i].first);
continue;
}
temp--;
ans = (ans + a[i].second - *temp);
myset.erase(temp);
myset.insert(a[i].se);
}
oi((int)myset.size()); oc; ol(ans); puts("");
}
return 0;
}
【2017 Multi-University Training Contest - Team 10】Schedule的更多相关文章
- 【2017 Multi-University Training Contest - Team 10 】Monkeys
[链接]点击打开链接 [题意] 给你一棵n节点的树,现在让你放k个猴子,可以删边,问最少可以剩余几条边,放k个猴子,满足任意一个猴 子至少与一只猴子相连.2<=k<=n<=1e5 [ ...
- 【2017 Multi-University Training Contest - Team 2】TrickGCD
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6053 [Description] 给你一个b数组,让你求一个a数组: 要求,该数组的每一位都小于等 ...
- 【2017 Multi-University Training Contest - Team 2】Maximum Sequence
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6047 [Description] 给你一个数列a和一个数列b; 只告诉你a的前n项各是什么; 然后 ...
- 【2017 Multi-University Training Contest - Team 2】 Regular polygon
[Link]: [Description] 给你n个点整数点; 问你这n个点,能够组成多少个正多边形 [Solution] 整点只能构成正四边形. 则先把所有的边预处理出来; 枚举每某两条边为对角线的 ...
- 【2017 Multi-University Training Contest - Team 2】 Is Derek lying?
[Link]: [Description] 两个人都做了完全一样的n道选择题,每道题都只有'A','B','C' 三个选项,,每道题答对的话得1分,答错不得分也不扣分,告诉你两个人全部n道题各自选的是 ...
- 【2017 Multi-University Training Contest - Team 4】Time To Get Up
[Link]: [Description] [Solution] 把每个数字长什么样存到数组里就好;傻逼题. (直接输入每一行是什么样子更快,不要一个字符一个字符地输入) [NumberOf WA] ...
- 【2017 Multi-University Training Contest - Team 7】Hard challenge
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=6127 [Description] 平面上有n个点,每个点有一个价值,每两个点之间都有一条线段,定义 ...
- 【2017 Multi-University Training Contest - Team 7】Kolakoski
[Link]:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=765 [Description] 有一种 ...
- 【2017 Multi-University Training Contest - Team 9】FFF at Valentine
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=6165 [题意] 一张有向图,n个点,m条边,保证没有重边和自环.询问任意两个点能否满足任何一方能够到达另 ...
随机推荐
- Svn备份与Bandizip压缩批处理程序
目的:为了定时备份多个svn仓库数据,使用批处理程序进行备份并Bandizip进行压缩保存到指定位置,操作完成后弹出成功提示. 为了完成以上目标,需要了解以下几个方面: 批处理命令 Svn命令 Ban ...
- Django_模板HTML
- php验证邮箱,手机号是否正确
function is_valid_email($email)//判断是不是邮箱的函数{ return preg_match('/^[a-zA-Z0-9._%-]+@([a-zA-Z0-9.-] ...
- HOJ——T 1867 经理的烦恼
http://acm.hit.edu.cn/hoj/problem/view?id=1867 Source : HCPC 2005 Spring Time limit : 2 sec Memo ...
- 測试password强度
<html> <!--激情在最后面.请看最后面红色字 这是是个计算password强度的实例 网上有非常多这种样例 只是呢,都不怎么好 这是我写的一个完整的效果,能够通用, new一 ...
- IsoAlgo3d - IDF/PCF pipeline 3d viewer
IsoAlgo3d - IDF/PCF pipeline 3d viewer eryar@163.com Key Words. IDF, PCF, IsoAlgo, 3D 当前国际主流管道设计软件都可 ...
- OpenCascade Sweep Algorithm
OpenCascade Sweep Algorithm eryar@163.com Abstract. Sweeps are the objects you obtain by sweeping a ...
- Dynamics CRM 2015/2016 Web API:Unbound Custom Action 和 Bound Custom Action
今天我们再来看看Bound/Unbound Custom Action吧,什么是Custom Action?不知道的小伙伴们就out了,Dynamics CRM 2013就有了这个功能啦.和WhoAm ...
- hdu 1875 畅通project再续(kruskal算法计算最小生成树)
畅通project再续 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- button-xml 中android:clickable="false" 属性
今天在做项目的时候,遇到了一个问题,就是需要把一个常按监听事件,加到一个linearlayout中,但是,这个linearlayout中有其他的button.textview等控件,这样就导致当我们常 ...