Codeforces Round #413(Div. 1 + Div. 2, combined)——ABCD
题目在这里
A.Carrot Cakes
乱七八糟算出两个时间比较一下就行了
又臭又长仅供参考
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j;i <= k;i ++)
#define rev(i, j, k) for(int i = j;i >= k;i --)
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
int n, t, k, d;
cin >> n >> t >> k >> d;
int t1 = (n + k - ) / k * t;
int t2 = ;
int t3 = (n + k - ) / k;
int t4 = (d + t - ) / t;
int t5 = t3 - t4;
if(t5 & ) t2 = d + (t5 + ) / * t;
else t2 = t4 * t + t5 / * t;
if(t2 < t1) puts("YES");
else puts("NO");
return ;
}
B.T-shirt buying
颜色数只有三个,开三个优先队列就行了
然后同一件衣服不要重复卖
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j;i <= k;i ++)
#define rev(i, j, k) for(int i = j;i >= k;i --)
using namespace std;
const int maxn = ;
typedef long long ll;
struct node {
int x, y;
bool operator < (const node &a) const {
return x > a.x;
}
};
priority_queue <node> q[];
int n, m, v[maxn], a, b, p[maxn];
int main() {
ios::sync_with_stdio(false);
cin >> n;
rep(i, , n) cin >> p[i];
rep(i, , n) cin >> a, q[a].push((node){p[i], i});
rep(i, , n) cin >> b, q[b].push((node){p[i], i});
cin >> m;
rep(i, , m) {
cin >> a;
while(!q[a].empty() && v[q[a].top().y]) q[a].pop();
if(!q[a].empty()) cout << q[a].top().x << " ", v[q[a].top().y] = , q[a].pop();
else cout << "-1 ";
}
return ;
}
C.Fountains
三种情况,都用c或d买,一个c一个d
第三种肥肠简单的
前面两种的话
对于新插入的物品,如果价格为x
那么查询一下价格<=(c-x)的物品中的最大beauty
然后两个物品组合一下就行了
查询的话,直接树状数组就可以了,O(nlogn)
需要注意保证是两个不同物品,不能只有一个
#include <bits/stdc++.h>
#define lb(x) (x & (-x))
#define rep(i, j, k) for(int i = j;i <= k;i ++)
#define rev(i, j, k) for(int i = j;i >= k;i --)
using namespace std;
typedef long long ll;
struct node{
int x, y;
char str[];
void init() {
scanf("%d %d %s", &x, &y, str);
}
}a[];
int n, c, d, e, c1[], c2[];
int ask(int *C, int i) {
int ret = ;
while(i > ) ret = max(ret, C[i]), i -= lb(i);
return ret;
}
void ins(int *C, int i, int x) {
while(i <= e) C[i] = max(C[i], x), i += lb(i);
}
int main() {
cin >> n >> c >> d, e = max(c, d);
int t1 = , t2 = , t3, t4 = , t5 = , ans = ;
rep(i, , n) {
a[i].init();
if(a[i].str[] == 'C' && a[i].y <= c) {
if(a[i].x > t1) t1 = a[i].x;
t3 = ask(c1, c - a[i].y);
if(t3 != && a[i].x + t3 > t4) t4 = a[i].x + t3;
ins(c1, a[i].y, a[i].x);
}
if(a[i].str[] == 'D' && a[i].y <= d) {
if(a[i].x > t2) t2 = a[i].x;
t3 = ask(c2, d - a[i].y);
if(t3 != && a[i].x + t3 > t5) t5 = a[i].x + t3;
ins(c2, a[i].y, a[i].x);
}
}
ans = max(t4, t5);
if(t1 != && t2 != && t1 + t2 > ans) ans = t1 + t2;
cout << ans;
return ;
}
我还肥肠脑残地,取消了cin与stdio的同步后
同时用cin和scanf,然后WA了一发...
D.Field expansion
显然ans最大就是loga级别的
所以我们直接暴搜就行了
然后考虑到很骚的情况
a = b = 10W h = w = 1
ai = 2 n = 10W
这样的话我们用map防重就好了
很重要的一件事情 :
注意到题意说能放下
所以并没有h一定对应a,w一定对应b
也可以试试h怼b,w怼a!
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j;i <= k;i ++)
#define rev(i, j, k) for(int i = j;i >= k;i --)
using namespace std;
typedef long long ll;
int a, b, h, w, n, c[];
bool cmp(int x, int y) {
return x > y;
}
typedef pair<ll, ll> node;
vector <node> e;
map <node,bool> p;
int main() {
ios::sync_with_stdio(false);
cin >> a >> b >> h >> w >> n;
rep(i, , n) cin >> c[i];
sort(c + , c + n + , cmp);
node tmp;
if(h >= a && w >= b || w >= a && h >= b) {puts("");return ;}
e.push_back(make_pair(h, w));
for(int i = ;i <= n;i ++) {
int t = e.size();
for(int j = ;j < t;j ++) {
if(e[j].first < a) {
tmp = make_pair(e[j].first * c[i], e[j].second);
if(!p[tmp]) e.push_back(tmp), p[tmp] = ;
}
if(e[j].second < b) {
tmp = make_pair(e[j].first, e[j].second * c[i]);
if(!p[tmp]) e.push_back(tmp), p[tmp] = ;
}
}
for(int j = ;j < e.size();j ++) {
if(e[j].first >= a && e[j].second >= b || e[j].first >= b && e[j].second >= a) {
cout << i;
return ;
}
}
}
puts("-1");
return ;
}
Codeforces Round #413(Div. 1 + Div. 2, combined)——ABCD的更多相关文章
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 39 (Rated for Div. 2) G
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
- Educational Codeforces Round 60 (Rated for Div. 2) 题解
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...
随机推荐
- 【POJ 3263】 Tallest Cow
[题目链接] http://poj.org/problem?id=3263 [算法] 若A和B两头牛可以互相看见,那么说明中间的牛的高度都至少比它们少1,因此,我们可以引入一个差分数组c 对于每组关系 ...
- P2657 [SCOI2009]windy数 数位dp
数位dp之前完全没接触过,所以NOIP之前搞一下.数位dp就是一种dp,emm……用来求解区间[L,R]内满足某个性质的数的个数,且这个性质与数的大小无关. 在这道题中,dp[i][j]代表考虑了i位 ...
- bzoj1227
离散化+树状数组+排列组合 很久以前就看到过这道题,现在依然不会做...看完题解发现思路很简单,就是有点难写 我们先将坐标离散化,x和y最大是w,然后我们就有了一个暴力做法, 枚举每块墓地,统计,因为 ...
- 要自己当技术使用astgo运营网络电话系统,必须掌握的基本技术
知道什么是centos 知道怎么远程访问centos服务器 (常用工具 Secure Shell Client.WINSCP) 知道重启服务器的命令是 reboot 知道你的服务器是没有图形界面的,所 ...
- 【转载】SSH框架总结(框架分析+环境搭建+实例源码下载)
首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是目前较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...
- Django - 自定义请求头
收藏一下以后学习 博客搬运地址 Django接收自定义http header(转)
- 【废弃】【WIP】JavaScript 函数
创建: 2017/10/09 更新: 2017/11/03 加上[wip] 废弃: 2019/02/19 重构此篇.原文归入废弃 增加[废弃中]标签与总体任务 结束: 2019/03/12 完成废弃 ...
- 【WIP】Bootstrap nav
创建: 2017/09/28 更新: 2017/10/14 标题加上[WIP]
- 【洛谷3321_BZOJ3992】[SDOI2015]序列统计(原根_多项式)
题目: 洛谷3321 分析: 一个转化思路比较神(典型?)的题-- 一个比较显然的\(O(n^3)\)暴力是用\(f[i][j]\)表示选了\(i\)个数,当前积在模\(m\)意义下为\(j\)的方案 ...
- 【POJ1845】Sumdiv(数论/约数和定理/等比数列二分求和)
题目: POJ1845 分析: 首先用线性筛把\(A\)分解质因数,得到: \[A=p_1^{a_1}*p_2^{a_2}...*p_n^{a_n} (p_i是质数且a_i>0) \] 则显然\ ...