Topcoder SRM 726 Hard
来源:互联网 发布:ug4轴编程视频 编辑:程序博客网 时间:2024/06/01 09:39
链接:
link
题意:
有
题解:
不难发现这是个拟阵,所以可以从大到小排序之后贪心。
考虑对于一组区间,如何判断它是否合法也可以贪心:从左到右扫,每个位置安排
考虑插入一个区间
举个例子,
每次放完一个区间之后暴力算出哪些合法,用
复杂度
代码:
#include <bits/stdc++.h>#define xx first#define yy second#define mp make_pair#define pb push_back#define mset(x, y) memset(x, y, sizeof x)#define mcpy(x, y) memcpy(x, y, sizeof x)using namespace std;typedef long long LL;typedef pair <int, int> pii;const int MAXN = 2005;const int mod = 1e9 + 7;class HeroicSchedule{ int m, ans, rig[MAXN]; vector <int> r[MAXN]; vector <pii> a[MAXN]; set <int> s; inline void Solve() { s.clear(); multiset <int> cur; for (int i = 0; i < m; i ++) { for (auto j : r[i]) cur.insert(j); if (cur.empty()) rig[i] = m; else rig[i] = *cur.begin(), cur.erase(cur.begin()); } for (int i = m - 1; ~i; i --) if (rig[i] == m || (!s.empty() && *s.begin() <= rig[i])) s.insert(i); } public: int getmax(int n, int A, int B, int C, int modStart, int modLen, int modCost) { ans = 0; for (int i = 1, x = A, y, z; i <= n; i ++, x = (1LL * z * B + C) % mod) y = (1LL * x * B + C) % mod, z = (1LL * y * B + C) % mod, a[z % modCost].pb(mp(x % modStart, y % modLen + x % modStart)); m = modStart + modLen - 1; for (int i = 0; i < m; i ++) s.insert(i); for (int i = modCost - 1; i; i --) for (auto e : a[i]) if (!s.empty() && *s.rbegin() >= e.xx && *s.lower_bound(e.xx) <= e.yy) ans += i, r[e.xx].pb(e.yy), Solve(); return ans; }};
阅读全文
0 0
- Topcoder SRM 726 Hard
- Topcoder SRM 716 Hard
- Topcoder SRM 718 Hard
- Topcoder SRM 720 Hard
- Topcoder SRM 505 Div 2 hard
- Topcoder SRM 663 Div2 Hard: CheeseRolling(状压DP)
- TopCoder SRM 281
- 第一次参加Topcoder SRM
- topcoder SRM 503报告
- topcoder SRM 506
- topcoder SRM 513 DIV2
- Topcoder SRM 495 - 513
- TopCoder SRM 543 DIV2
- topcoder-srm-233-div2
- Topcoder SRM 566 countJourneys
- TopCoder SRM 473 题解
- Topcoder SRM 573 WolfPackDivTwo
- Topcoder SRM Div2 Level2
- splay操作集合
- 随机生成个数50和20的字符串分别存在file1,file2中并将在file1中出现且不在file2中的字符存在flie3中
- 无限轮播1
- 有无条件分页查询
- 进程与线程的关系及区别
- Topcoder SRM 726 Hard
- layer关闭弹窗 (弹窗easyui:为datagrid添加radio单选框)
- 斐波拉契数列(Fibonacci)
- 无限轮播2
- JavaScript~ajax~城市三级联动
- linux 安装jdk
- 160个练手CrackMe-041
- 数据结构实验之排序一:一趟快排
- protocolBuf的跨平台基础使用1