题意:给出最后的时间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【贪心】的更多相关文章

  1. Codeforces 437C The Child and Toy(贪心)

    题目连接:Codeforces 437C  The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...

  2. Codeforces Round #546 (Div. 2) D 贪心 + 思维

    https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...

  3. 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 ...

  4. Codeforces Round #235 (Div. 2) B. Sereja and Contests

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. Codeforces Educational Codeforces Round 3 C. Load Balancing 贪心

    C. Load Balancing 题目连接: http://www.codeforces.com/contest/609/problem/C Description In the school co ...

  7. Codeforces Testing Round #12 B. Restaurant 贪心

    B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...

  8. Codeforces 437D The Child and Zoo(贪心+并查集)

    题目链接:Codeforces 437D The Child and Zoo 题目大意:小孩子去參观动物园,动物园分非常多个区,每一个区有若干种动物,拥有的动物种数作为该区的权值.然后有m条路,每条路 ...

  9. CodeForces - 777B Game of Credit Cards 贪心

    题目链接: http://codeforces.com/problemset/problem/777/B 题目大意: A, B玩游戏,每人一串数字,数字不大于1000,要求每人从第一位开始报出数字,并 ...

随机推荐

  1. Process Explorer

    https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer Ever wondered which program ...

  2. hdoj--1950--Bridging signals(二分查找+LIS)

    Bridging signals Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. systemd服务管理---systemctl命令列出所有服务

    1.列出系统所有服务 #systemctl list-units --all --type=service

  4. P2742 [USACO5.1]圈奶牛Fencing the Cows

    题目描述 农夫约翰想要建造一个围栏用来围住他的奶牛,可是他资金匮乏.他建造的围栏必须包括他的奶牛喜欢吃草的所有地点.对于给出的这些地点的坐标,计算最短的能够围住这些点的围栏的长度. 输入输出格式 输入 ...

  5. QT笔记 -- (3) 为QLabel添加鼠标响应方法1

    参考 http://qt-project.org/wiki/Make-a-QLabel-Clickable 1.首先重载QLabel的mousePressEvent,这样点击QLabel时就能发出cl ...

  6. ASM磁盘组中的AU与条带

    一.AU与条带(AU和条带就是一个分配单位,数据会被以一定单位分割,存储在多个磁盘中.分割单位的大小由AU.条带来决定. ASM有两种条带: 1.不可调粗粒度: 相当于ASM没有条带,或者说AU就是条 ...

  7. 性能测试中的TPS与HPS

    性能测试中的TPS与HPS TPS(Transaction per second) 是估算应用系统性能的重要依据.其意义是应用系统每秒钟处理完成的交易数量.一般的,评价系统性能均以每秒钟完成的技术交易 ...

  8. parted 4T磁盘

    parted /dev/vdg mklabel gpt mkpart primary ext4 0% 100%

  9. 【问题】解决python3不支持mysqldb

    Django框架使用的还是python2.x的MySQLdb,而python3.x使用的是pymysql,centos7上默认安装的python2.7,自己安装了python3.6的版本,在运行dja ...

  10. 紫书 习题8-7 UVa 11925(构造法, 不需逆向)

    这道题的意思紫书上是错误的-- 难怪一开始我非常奇怪为什么第二个样例输出的是2, 按照紫书上的意思应该是22 然后就不管了,先写, 然后就WA了. 然后看了https://blog.csdn.net/ ...