UVALive 7512 November 11th(脑洞)

17 篇文章 0 订阅
4 篇文章 0 订阅

题目链接:点击打开链接

给出坏凳子的位置, 座位不能挨着坐, 问最多可以做多少人, 以及最少可以坐多少人使得不能再有可以坐的位置.

最多可以坐多少人, 只要中间空一个即可, 本题wa点在最少坐的人数, 中间空两个也可以... 比如.S..S.所以空的位置大于2时, 分母为3.

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "stack"
#include "cmath"
#include "utility"
#include "map"
#include "set"
#include "vector"
#include "list"
#include "string"
#include "cstdlib"
using namespace std;
typedef long long ll;
#define X first
#define Y second
#define exp 1e-8
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1005;
int t, r, s, b;
std::vector<int> v[MAXN];
int main(int argc, char const *argv[])
{
	scanf("%d", &t);
	for(int cas = 1; cas <= t; ++cas) {
		for(int i = 0; i < MAXN; ++i)
			v[i].clear();
		int ans1 = 0, ans2 = 0;
		scanf("%d%d", &r, &s);
		scanf("%d", &b);
		while(b--) {
			int x, y;
			scanf("%d%d", &x, &y);
			v[x].push_back(y);
		}
		for(int i = 0; i < r; ++i) {
			sort(v[i].begin(), v[i].end());
			v[i].push_back(s);
		}
		for(int i = 0; i < r; ++i) {
			int x = -1;
			for(int j = 0; j < v[i].size(); ++j) {
				int len = v[i][j] - x - 1;
				x = v[i][j];
				if(len <= 0) continue;
				if(len <= 2) {
					ans1++;
					ans2++;
				}
				else {
					ans1 += (len + 1) / 2;
					ans2 += (len + 2) / 3;
				}
			}
		}
		printf("Case #%d: %d %d\n", cas, ans1, ans2);
	}
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值