codeforces 401 B Sereja and Contests【贪心】
题意:给出最后的时间n,div 1必须和div2一起举行,并且div2的时间总是比div1大1
给出Sereja(只能参加div2)参加过的k场比赛的时间,问他最少错过了多少场div2,最多错过了多少场div 2
先扫描一遍单个的没有用过的时间,再扫一遍连续的两个没有用过的时间
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; #define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i) typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=; int hash[maxn]; int main(){
int n,m;
cin>>n>>m;
memset(hash,,sizeof(hash)); while(m--){
int x,u,v;
cin>>x;
if(x==){
cin>>u>>v;
hash[u]=hash[v]=;
}
if(x==) {
cin>>u;
hash[u]=;
}
} int minn=,maxx=; for(int i=;i<n;i++){
if(hash[i]==) maxx++;
} for(int i=;i<n-;i++){
if(hash[i]==&&hash[i+]==) {
minn++;
hash[i]=;
hash[i+]=;
}
} printf("%d %d\n",maxx-minn,maxx);
return ;
}
读题读了好久的说啊-------------- gooooooooooooo
codeforces 401 B Sereja and Contests【贪心】的更多相关文章
- Codeforces 437C The Child and Toy(贪心)
题目连接:Codeforces 437C The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...
- Codeforces Round #546 (Div. 2) D 贪心 + 思维
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...
- codeforces 235 div2 B. Sereja and Contests
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good ...
- Codeforces Round #235 (Div. 2) B. Sereja and Contests
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- Codeforces Educational Codeforces Round 3 C. Load Balancing 贪心
C. Load Balancing 题目连接: http://www.codeforces.com/contest/609/problem/C Description In the school co ...
- Codeforces Testing Round #12 B. Restaurant 贪心
B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...
- Codeforces 437D The Child and Zoo(贪心+并查集)
题目链接:Codeforces 437D The Child and Zoo 题目大意:小孩子去參观动物园,动物园分非常多个区,每一个区有若干种动物,拥有的动物种数作为该区的权值.然后有m条路,每条路 ...
- CodeForces - 777B Game of Credit Cards 贪心
题目链接: http://codeforces.com/problemset/problem/777/B 题目大意: A, B玩游戏,每人一串数字,数字不大于1000,要求每人从第一位开始报出数字,并 ...
随机推荐
- 为什么不能用memcached存储Session?
Memcached创建者Dormando非常早就写过两篇文章[1][2].告诫开发者不要用memcached存储Session. 他在第一篇文章中给出的理由大致是说,假设用memcached存储Ses ...
- 编程与算法中的端点问题(linspace(a, b, n),endpoint)
左闭右开,[0, n) ⇒ [0, n-1],共 n 个元素: 1. 列表长与编号 列表(seq,也可以是数组等线性结构)的长度要比末尾元素的编号多 1,比如一个列表内含有 5 个元素,最后一个元素的 ...
- [JZOJ 5912] [NOIP2018模拟10.18] VanUSee 解题报告 (KMP+博弈)
题目链接: https://jzoj.net/senior/#contest/show/2530/2 题目: 众所周知,cqf童鞋对哲学有着深入的理解和认识,并常常将哲学思想应用在实际生活中,例如锻炼 ...
- java算法数据结构
原文地址:github.com/kdn251/interviews 译文出自:掘金翻译计划 译者:王下邀月熊 校对者:PhxNirvana.根号三 这个 链接 用来查看本翻译与英文版是否有差别(如果你 ...
- (转载)自定义ExpandableListView,实现二级列表效果
先看效果图: 上图是我们要实现的效果,那么现在我们开始着手去做,主要分为以下几步: 一丶我们需要根据效果图去思考该如何动手,从上图分析看,我们可以用一个相对布局RelativeLayout来完成gro ...
- Java数据库连接——PreparedStatement的使用
首先了解Statement和PreparedStatement的区别: 由此可见,一般使用PreparedStatement. 操作数据库SU(Course表),其中Course属性有Cno,Cnam ...
- python 时间差计算
import time import datetime datebg=input("date begin:") dateed=input("date end:" ...
- HDU 1506 Largest Rectangle in a Histogram【DP】
题意:坐标轴上有连续的n个底均为1,高为h[i]的矩形,求能够构成的最大矩形的面积. 学习的别人的代码 @_@ 看底的坐标怎么找的看了好一会儿--- 记l[i]为矩形的底的左边的坐标,就将它一直向左扩 ...
- 路飞学城Python-Day17
[1.编程范式] 1.面向过程编程 2.面向对象编程 [2.面向过程编程] 面向过程:核心就是过程 什么是过程? 过程指的是解决问题的步骤,先做什么,在作什么,面向过程就像是设计一个流水线,是一种 ...
- 【转载】02-PowerDesigner的下载及安装
原创路径:https://blog.csdn.net/ruyu00/article/details/79842807 一.下载 下载路径:https://pan.baidu.com/s/1WD7QHT ...