UVALive 7512 November 11th 题解
思路:心态大崩,最多不讲了,最少应该是三个一组,比如......应该是.S..S.,这样占的最多
代码:
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn = + ;
const int MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
int row[maxn][maxn], cnt[maxn];
int getMax(int s){
return (s + ) / ;
}
int getMin(int s){
if(s % == ){
return s / ;
}
else if(s % == ){
return (s + ) / ;
}
else return (s + ) / ;
}
int main(){
int t, ca = ;
scanf("%d", &t);
while(t--){
int b, r, s;
scanf("%d%d", &r, &s);
scanf("%d", &b);
memset(cnt, ,sizeof(cnt));
for(int i = ; i <= b; i++){
int x, y;
scanf("%d%d", &x, &y);
row[x][cnt[x]++] = y;
}
int Max = , Min = ;
for(int i = ; i < r; i++){
if(cnt[i] == ){
Max += getMax(s);
Min += getMin(s);
}
else{
sort(row[i], row[i] + cnt[i]);
for(int j = ; j < cnt[i]; j++){
if(j == ){
int tmp = row[i][j] - ;
Max += getMax(tmp);
Min += getMin(tmp);
}
else{
int tmp = row[i][j] - row[i][j - ] - ;
Max += getMax(tmp);
Min += getMin(tmp);
}
}
int tmp = s - - row[i][cnt[i] - ];
Max += getMax(tmp);
Min += getMin(tmp);
}
}
printf("Case #%d: %d %d\n", ca++, Max, Min);
}
return ;
}
/*
3
2 3
1
0 1
2 3
0
1 1
1
0 0
*/
UVALive 7512 November 11th 题解的更多相关文章
- UVaLive 7512 November 11th (思维漏洞)
题意:给定n*m个座椅,然后有b个是坏的,要做人,并且两个人不能相邻,问你最多坐多少人,最少坐多少人. 析:这个题其实并不难,只要当时一时没想清楚,结果就一直WA,就是最少的情况时,其实一个人可以占三 ...
- UVALive 6124 Hexagon Perplexagon 题解
http://vjudge.net/problem/viewProblem.action?id=37480 East Central Regional Contest Problem C: Hexag ...
- UVALive 2521 Game Prediction 题解
这个我上来把题目理解错了,我以为所有人的牌都是一样的,感觉这个题太麻烦了吧,而且题目样例过不去啊……后来发现理解错了,给出的数据是他一个人的数据,就是让我们求他一定能赢的轮数,所有的牌是固定的(1 - ...
- November 11th 2016 Week 46th Friday
Keep in mind that neither success nor failure is ever final. 无论成败,皆非定局. The final is not coming, but ...
- November 11th, 2017 Week 45th Saturday
Happiness is a direction, not a place. 快乐是一个方向,不是一个目的. Do you remember those moments in your life wh ...
- The 2013 South America/Brazil Regional Contest 题解
A: UVALive 6525 cid=61196#problem/A" style="color:blue; text-decoration:none">Atta ...
- 2015 ACM/ICPC EC-Final
A. Boxes and Balls 二分找到最大的不超过$n$的$\frac{x(x+1)}{2}$形式的数即可. #include <bits/stdc++.h> using name ...
- 任务调度框架-Quartz.Net
使用Quartz.Net依赖于以下3个组件:Common.Logging.dll.Common.Logging.Core.dll.Quartz.dll 简单封装 using Quartz; using ...
- Quartz.net(调度框架) 使用Mysql作为存储
最近公司的做的项目中涉及到配置任务地址然后按照配置去目标地址提取相关的数据,所以今天上午在Internet上查看有关定时任务(调度任务)的相关信息,筛选半天然后查找到Quartz.net. Quart ...
随机推荐
- windows中查看端口占用情况
说几个命令, netstat 用于查看进程端口占用情况,用法可以使用netstat -h 查看 tasklist 列出当前进程,有进程号 findstr 用于过滤字符串 大致过程就是: 1. 使用 n ...
- Yii2返回以主键id为键名的数组
branch.php <?php namespace app\models; use Yii; /** * This is the model class for table "bra ...
- html5-table布局
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- caffe生成voc格式lmdb
要训练ssd基本都是在liu wei框架下改,生成lmdb这一关照葫芦画瓢总遇坑,记录之: 1. labelmap_voc.prototxt要根据自己的分类修改,比如人脸检测改成这样: item { ...
- 使用Java函数接口及lambda表达式隔离和模拟外部依赖更容易滴单测
概述 单测是提升软件质量的有力手段.然而,由于编程语言上的支持不力,以及一些不好的编程习惯,导致编写单测很困难. 最容易理解最容易编写的单测,莫过于独立函数的单测.所谓独立函数,就是只依赖于传入的参数 ...
- 设计模式之Chain of Responsibility(职责链)(转)
Chain of Responsibility定义 Chain of Responsibility(CoR) 是用一系列类(classes)试图处理一个请求request,这些类之间是一个松散的耦合, ...
- Node.js中环境变量process.env详解
Node.js中环境变量process.env详解process | Node.js API 文档http://nodejs.cn/api/process.html官方解释:process 对象是一个 ...
- 一篇关于蓝牙SDP和L2CAP协议的文章
SDP地址:http://www.cnblogs.com/strive-forever/archive/2011/11/04/2236640.html L2CAP地址:http://www.cnblo ...
- usb通信小结
2010-07-25 16:52:00 目前了解了usb通信层面的一些基础知识如下.如果有空还要再了解hid报告描述符及协议的数据包波形. 一,USB的一些基本概念 1. 管道(Pipe) 是主机和设 ...
- Lambda表达式select()和where()的区别
可能很多同学和我一样对于select()和where()区别并不是太清晰,其实两者还是有本质区别的. 1.where()用法:必须加条件,且返回对象结果. static void Main(strin ...