250pt

在一个10^9 * 10^9大的剧院里,有最多47个位子有人,然后有一对couple想找一对左右相邻的位子,问有多少种选择方式。

思路:

总共有 n * (m-1)种方案,然后扣掉有人位置占掉的方案即可。

这里占掉位置我用一个set存储,正好可以去重。。

 #line 7 "TheMoviesLevelOneDivOne.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class TheMoviesLevelOneDivOne
{
public:
long long find(int n, int m, vector <int> row, vector <int> seat)
{
long long ans = n;
ans =ans * (m - );
set< PII > S;
for (int i = ; i < row.size(); ++i){
if (seat[i] > ) S.insert(make_pair(row[i], seat[i]));
if (seat[i] + <= m) S.insert(make_pair(row[i], seat[i] + ));
}
ans -= S.size();
return ans;
} };

500pt

题意:一个人看电影,该人有一个scare值,并且没看1min电影scare减1。有很多部恐怖电影,每部电影长度不同(length[i]),且每部都有一个瞬间增加scare(s[i])值的时刻。如果scare值小于0,则这个人就会睡着,不能再看电影。请问他安排一个电影观看顺序,使得他能看尽可能多的电影。如果有多组观看顺序看到的电影数相同,则输出字典序最小的。(电影数量小等于20)

思路:

状态压缩。。

 #line 7 "TheMoviesLevelTwoDivOne.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;
int dp[ << ]; class TheMoviesLevelTwoDivOne
{
public:
vector <int> find(vector <int> L, vector <int> scary)
{
int n = L.size();
memset(dp, , sizeof(dp));
for (int i = ; i < ( << n); ++i){
int level = ;
for (int j = ; j < n; ++j)
if (!(i & ( << j))) level += - L[j];
for (int j = ; j < n; ++j) if (i & ( << j))
if (level >= scary[j] && level + - L[j] >= )
dp[i] = max(dp[i], dp[i ^ ( << j)] + );
}
vector<int> ans;
int x = , mask = ( << n) - ;
while (mask > ){
for (int i = ; i < n; ++i) if (mask & ( << i))
if (dp[mask] == ||
(x >= scary[i] && x + - L[i] >= && dp[mask ^ ( << i)] == dp[mask] - )){
ans.PB(i);
mask ^= ( << i);
x += - L[i];
break;
}
}
return ans;
}
};

SRM469的更多相关文章

  1. SRM468 - SRM469(1-250pt, 500pt)

    SRM 468 DIV1 250pt 题意:给出字典,按照一定要求进行查找. 解法:模拟题,暴力即可. tag:water score: 0.... 这是第一次AC的代码: /* * Author: ...

  2. Topcoder 好题推荐

    SRM SRM147 DIV1 1000pt DP SRM148 DIV1 1100pt 递归 SRM149 DIV1 1000pt math SRM150 DIV1 500pt DP SRM469 ...

随机推荐

  1. String 练习

    package com.hanqi; import java.util.Random; public class Text { public static void main(String[] arg ...

  2. postfix发信提示 Error: too many connectino from

    查看提示,很明显是提示连接数过多导致的. 有提示上面的信息,看提示的IP地址是一个网关的地址,使用netstat -ano|grep ':25'|wc -l 看了下,25端口的连接的IP地址,几乎全是 ...

  3. Servlet 3.0 规范(二)注解驱动和异步请求

    Servlet 3.0 规范(二)注解驱动和异步请求 在 Servlet 3.0 时支持注解启动,不再需要 web.xml 配制文件. 一.Servlet 3.0 组件 Servlet 容器的组件大致 ...

  4. SVN 钩子 同步测试服务器

    http://blog.csdn.net/showso2006/article/details/6750441 多人开始使用subversion之后,就想着,要建立一个测试用的服务器,不需要把文件up ...

  5. hbase 无法打开60010网页

    在hbase-site.xml中添加如下节点 <property> <name>hbase.master.info.port</name> <value> ...

  6. SpringBoot的读取properties文件的方式

    转载:https://www.imooc.com/article/18252一.@ConfigurationProperties方式 自定义配置类:PropertiesConfig.java pack ...

  7. PHP函数可变参数

    PHP自定义函数中支持可变数量的参数 在PHP 5.5 及更早的版本中,使用函数func_num_args() , func_get_arg() , func_get_args()实现: 我们举个例子 ...

  8. tms web core 通过URL 传递参数

    一般我们都会通过URL 给服务器传递很多参数,通过参数来决定对应的处理,今天就大概讲一下 如果通过URL 参数实现一些功能. 1.通过参数跳入不同的界面 首先我们先建立一个tms web core 工 ...

  9. mysql 初始密码、修改密码

    新装MySQL,进不去,找不到网上说的什么临时密码,也没有见到放临时密码的文件,历经坎坷,终解决,,在此记录,谨防下次忘记,在此感谢原作者博文 系统 Ubuntu18.04 mysql Ver 14. ...

  10. 22.上传app一些相关问题

    1.截取上传的各个屏幕尺寸 1.按最大尺寸截取,快捷键 command+s 2.在模拟器上截取 3. 截图 iphone4 : 640x960 或者 960x640 phone5    640 x 1 ...