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 ...
随机推荐
- mysql优化(四)
一.对查询进行优化,要尽量避免全表扫描,首先应考虑在 where / group by / order by 涉及的列上建立索引. 1.索引失效情况. SQL什么条件会使用索引? 当字段上建有索引时, ...
- 区别JS中类的静态方法,静态变量,实例方法,实例变量
1.类的静态方法 先来段代码之后分析 // JS类静态函数 function BaseClass() { } // 类添加add函数 BaseClass.add = function() { cons ...
- hdu4778 状态压缩
#include <iostream> #include <algorithm> #include <cstdio> #include <vector> ...
- 修改 File --> New 菜单内容
修改 File --> New 菜单内容 window --> Perspective --> Customize Perspective
- python locust 性能测试:locust安装和一些参数介绍
安装参考 https://www.cnblogs.com/fnng/p/6081798.html <虫师大大的,很详细> ps:python3.7暂不支持locust:python3安装建 ...
- Linux基础命令---join
join 找出两个文件中相同的字段,根据相同字段合并两个文件,将合并结果显示到标准输出. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora ...
- Symfony2 学习笔记之控制器
一个controller是你创建的一个PHP函数,它接收HTTP请求(request)并创建和返回一个HTTP回复(Response).回复对象(Response)可以是一个HTML页面,一个XML文 ...
- php中生成标准uuid(guid)的方法
);// "}" return $uuid; }}echo guid();?>
- shell 中的小技巧
去掉最后一个字符 sed 's/.$//' awk '{sub(/.$/,"")}1' awk '{printf $0"\b \n"}' [root@ ~]# ...
- OL6.3 设置本地yum源
仅在 Oracle Linux Server release 6.3 上测试 PS:Oracle Linux Server release 6.3仅用于测试,不能用于商业用途 [root@oracle ...