题目在这里

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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  4. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  5. 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 ...

  6. 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 ...

  7. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  8. 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 < ...

  9. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  10. Educational Codeforces Round 60 (Rated for Div. 2) 题解

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

随机推荐

  1. bzoj1143: [CTSC2008]祭祀river && bzoj27182718: [Violet 4]毕业旅行

    其实我至今不懂为啥强联通缩点判入度会错... 然后这个求的和之前那道组合数学一样,就是最长反链=最小链覆盖=最大独立集. #include<cstdio> #include<iost ...

  2. Bing Maps进阶系列二:使用GeocodeService进行地理位置检索

    Bing Maps进阶系列二:使用GeocodeService进行地理位置检索 在<Bing Maps进阶系列一:初识Bing Maps地图服务>里已经对GeocodeService的功能 ...

  3. WebView播放H5课件时,锁屏解锁后,页面重新绘制的问题

    难题描述:H5页面播放 ,锁屏,解锁后,重新加载了页面,三星不会出现(onpause onstop ,onresume),但在小米.魅族会调用 onpause onstop ondestroy,onr ...

  4. qtree4

    https://zybuluo.com/ysner/note/1236834 题面 给出一棵边带权的节点数量为\(n\)的树,初始树上所有节点都是白色.有两种操作: 改变节点\(x\)的颜色,即白变黑 ...

  5. 使用GitHub(转载)

    转自:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137628548491 ...

  6. 常见的Java Script内存泄露原因及解决方案

    前言 内存泄漏指由于疏忽或错误造成程序未能释放已经不再使用的内存.内存泄漏并非指内存在物理上的消失,而是应用程序分配某段内存后,由于设计错误,导致在释放该段内存之前就失去了对该段内存的控制,从而造成了 ...

  7. CSS发布时间

    * 1996年W3C正式推出了CSS1.* 1998年W3C正式推出了CSS2.* CSS2.1是W3C现在正在推荐使用的.* CSS3现在还处于开发中.

  8. Linux命令(002) -- free

    一.准备知识 Linux和Windows系统在内存管理机制方面有很大的不同.在Linux中经常发现空闲内存很少,似乎所有的内存都被系统占用了,表面感觉是内存不够用了,其实不然.这是Linux内存管理的 ...

  9. 【转】Java 集合系列06之 Vector详细介绍(源码解析)和使用示例

    概要 学完ArrayList和LinkedList之后,我们接着学习Vector.学习方式还是和之前一样,先对Vector有个整体认识,然后再学习它的源码:最后再通过实例来学会使用它.第1部分 Vec ...

  10. Java—break跳出语句

    在开发代码时,常常会产生这样的疑惑:break跳出语句是如何应用的呢? 使用break的场景有两种:一.switch语句中.二.循环语句. 这里就不介绍switch语句,主要说一下break在循环中的 ...