codeforces 1060 D
https://codeforces.com/contest/1060/problem/D
题意:你可以用1个及以上的圆桌,给n个人排座位,每个人左边需要有Li个空凳子,右边需要有Ri个空凳子,问你最少用多少个凳子
题解:一定要注意可以用多个圆桌,这样其实就是每个人的左边和右边无所谓,只需要求出左边或者右边的最大值即可,然后再加上本人的一个座位。
代码如下:
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <bitset>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#define PI acos(-1)
#define eps 1e-8
#define fuck(x) cout<<#x<<" = "<<x<<endl;
#define FIN freopen("input.txt","r",stdin);
#define FOUT freopen("output.txt","w+",stdout);
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int maxn = 1e5+;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
double dpow(double a,LL b){double ans=1.0;while(b){if(b%)ans=ans*a;a=a*a;b/=;}return ans;}
int l[maxn];
int r[maxn];
int main(){
#ifndef ONLINE_JUDGE
FIN
#endif
int n;
LL ans=;
cin>>n;
for(int i=;i<n;i++){
cin>>l[i]>>r[i];
}
sort(l,l+n);
sort(r,r+n);
for(int i=;i<n;i++){
ans+=(LL)max(l[i],r[i])+;
}
cout<<ans<<endl;
}
codeforces 1060 D的更多相关文章
- codeforces 1060 C
		https://codeforces.com/contest/1060/problem/C 题意:给你一个长度为n的数列a和长度为m的数列b,定义c(i,j)=ai*bj,得到c矩阵,给定值x,求c矩 ... 
- codeforces 1060 B
		https://codeforces.com/contest/1060/problem/B 题意:给你一个数C ,你要找到两个数A.B,使得A+B=C并且A的每个位的数的和最大,求最大的和是多少 题解 ... 
- codeforces 1060 A
		https://codeforces.com/contest/1060/problem/A 题意:电话号码是以8开头的11位数,给你n 个数问最多可以有多少个电话号码 题解:min(8的个数,n/11 ... 
- CodeForces 1060 B Maximum Sum of Digits
		Maximum Sum of Digits You are given a positive integer n. Let S(x)S(x) be sum of digits in base 10 r ... 
- Codeforces 1060 F. Shrinking Tree
		题目链接 一道思维好题啊...感觉这种类型的题很检验基本功是否扎实(像我这样的就挂了). 题意:你有一棵\(n\)个点的树,每次随机选择一条边,将这条边的两个端点合并,并随机继承两个点标号中的一个,问 ... 
- CodeForces Round #550 Div.3
		http://codeforces.com/contest/1144 A. Diverse Strings A string is called diverse if it contains cons ... 
- Codeforces 1060E(思维+贡献法)
		https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间 ... 
- Codeforces Round #513 by Barcelona Bootcamp  C. Maximum Subrectangle(双指针+思维)
		https://codeforces.com/contest/1060/problem/C 题意 给两个数组,a数组有n个元素,b数组有m个元素,两个数组元素互相相乘形成n*m的矩阵,找一个子矩阵,元 ... 
- Codeforces Round #513-ABCD
		ABC现场做出,涨了八十几分吧.D有点思路不知道怎么实现,赛后看题解发现巨简单,想得太复杂了.蓝瘦. A----http://codeforces.com/contest/1060/problem/A ... 
随机推荐
- 文件夹选项-安装功能-window服务
			我们初次使用windows10在显示一个文件的时候,可能不会将文件的扩展名显示出来,但是我们很多地方又需要更改文件的扩展名,打开文件的扩展名有两种方式 打开此电脑 ->>>点击右上方 ... 
- Kubernetes-设计理念(三)
			Kubernetes设计理念与分布式系统 分析和理解Kubernetes的设计理念可以使我们更深入的了解Kubernetes系统,更好的利用它管理分布式部署的云原生应用,另一方面也可以让我们借鉴其在分 ... 
- 3468-A Simple Problem with Integers 线段树(区间增减,区间求和)
			A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 110077 ... 
- Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory
			在hue上配置Mysql的时候,出现的错误: 发生服务器错误: Error loading MySQLdb module: libmysqlclient.so.18: cannot open sha ... 
- 【面试题】2018年最全Java面试通关秘籍第五套!
			[面试题]2018年最全Java面试通关秘籍第五套! 原创 2018-04-26 徐刘根 Java后端技术 第一套:<2018年最全Java面试通关秘籍第一套!> 第二套:<2018 ... 
- Scala学习笔记(二):运行脚本文件
			在某个目录(如:F:\)下新建一个文本文件,命名为:hello.scala 其内容为: println("Hello World!") 那么这个时候该怎么运行这个脚本文件呢? 通过 ... 
- OpenCV入门:(六:基础画图函数)
			有时程序中需要画一些基础的图形,例如直线,矩形,椭圆以及多边形.OpenCV中当然有此类函数. 1.函数介绍 直线line: , , ) img – 图像 pt1 – 直线起点 pt2 – 直线终点 ... 
- ADB常用指令
			adb 命令是adb程序自带的一些命令:adb shell则是调用Android系统的命令,Android系统特有的命令都放在Android设备的/system/bin目录中 MonkeyRunner ... 
- Tensorflow Estimators
			这篇文章介绍tf.estimator,一个高级TensorFlow API,可以极大简化机器学习编程.Estimators封装了下面几个活动. 训练 评估 预测 出口服务(export for ser ... 
- Halcon17无法加载"hdevenginecpp":找不到指定的模块
			Halcon17无法加载"hdevenginecpp":找不到指定的模块 在C#和Halcon17混合编程中,当执行private HDevEngine MyEngine = ne ... 
