A.Regular Bracket Sequence

题意

给你四种括号的数量,问是否存在一种组合方式让所有的括号匹配

思路

水题,怎么操作都可以。

AC代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void)
{ll l = 0, r = 0;int a, b, c, d;cin >> a >> b >> c >> d;l = a * 2 + b + c;r = b + c + d * 2;if (a == 0 && a == b && b == c && c == d)puts("1");else if (r == l){if (c != 0 && (a == 0 || d == 0))puts("0");elseputs("1");}elseputs("0");// system("pause");return 0;
}

B.Discounts

题意

给你一系列的糖果,你有一些优惠券,你可以选择等同于某张优惠券相同数字个的糖果,并将其中最便宜的那个糖果免费拿,之后其他糖果全价。问对于不同数字的优惠券,最便宜的购买方案是什么。

思路

水题,排个序然后选则比较贵的前几个就行。

AC代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 3 * 1e5 + 7;
ll p[maxn];
ll aa[maxn];
int main(void)
{ll n, m;ll ans = 0;scanf("%lld", &n);for (int i = 0; i < n; i++){scanf("%lld", &p[i]);ans += p[i];}sort(p, p + n, greater<ll>());scanf("%lld", &m);for (int i = 0; i < m; i++){scanf("%lld", &aa[i]);}for (int i = 0; i < m; i++){printf("%lld\n", ans - p[aa[i] - 1]);}// system("pause");return 0;
}

C.Painting the Fence

题意

有一些油漆工刷模板,每个人刷的范围不一样,现在撤掉两个油漆工,问撤掉之后最大能刷的面积是都少。

思路

先记录木板的每个部位被哪些油漆工刷了。然后统计每个油漆工对于只有一层油漆被刷的墙面的贡献,若一块墙面被两个油漆工刷了,统计一下这两个油漆工对于这块墙面的共同贡献。
之后暴力枚举一波,若删掉任意两个油漆工会让墙面少多少。少掉的数量就是:这两个油漆工对于当且仅当刷了一面墙的贡献加上他们俩合力刷了两面墙的贡献。

为什么超过三个油漆工刷过的墙面不统计?因为刷过三次的墙面怎么算贡献删掉两个油漆工都不会对这面墙有影响。

AC代码

#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 7;
int poi[maxn][3];
int one[maxn], two[maxn][maxn];
int main(void)
{std::ios::sync_with_stdio(false);int n, m;cin >> n >> m;for (int i = 0; i < m; i++){int x, y;cin >> x >> y;for (int j = x; j <= y; j++){if (poi[j][0] < 2){poi[j][++poi[j][0]] = i;}elsepoi[j][0]++;}}int sum = 0;for (int i = 1; i <= n; i++){int t = poi[i][0];//  cout << t << endl;if (t)sum++;if (t == 1)one[poi[i][1]]++;if (t == 2)two[poi[i][1]][poi[i][2]]++;}int cnt = 0x3f3f3f;for (int i = 0; i < m; i++){for (int j = i + 1; j < m; j++){cnt = min(cnt, one[i] + one[j] + two[i][j]);}}cout << sum - cnt << endl;//system("pause");return 0;
}

D.Stressful Training

题意

有N个学生,每个学生的电脑初始有一定量的电量,有一个充电器,每次可以给一个学生的电脑补充一定量的电,问最少需要每次补充的电量为多少即可让所有的学生都能挺过M的时间。

思路

二分寻找这个最小的充电电量,然后暴力贪心模拟,每次给电最少的学生充电。

怎么模拟呢?用有限队列维护每个学生电脑的电量,每个学生的电脑充一次电之后都可以继续运行一段的时间,每次统计从开始到每次充电之后学生电脑的总电量,除以耗电量,就是学生可以从开始坚持多少时间。然后若一开始学生坚持的时间小于当前时间,无疑是学生撑不到这个点了,返回false,若电量最少的学生能坚持的时间都比总时间长,那么直接范围true。可以完成模拟就说明当前这种充电的电量可以让每个学生坚持到最后,那么返回true。

AC代码

ps: 2994 ms

#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
#define ll long long
ll a[maxn], b[maxn], n, k;
typedef struct node
{ll time, id, power;bool operator<(const node &a) const{return this->time == a.time ? this->id > a.id : this->time > a.time;}
} poi;bool check(ll x)
{priority_queue<node> p;for (int i = 1; i <= n; i++){p.push(poi{a[i] / b[i], (ll)i, a[i]});}for (int i = 0; i < k; i++){poi t = p.top();p.pop();if (t.time < i)return false;if (t.time >= k)break;t.power += x;t.time = t.power / b[t.id];p.push(t);}return true;
}int main(void)
{std::ios::sync_with_stdio(false);cin >> n >> k;for (int i = 1; i <= n; i++)cin >> a[i];for (int i = 1; i <= n; i++)cin >> b[i];ll l = 0, r = 1e13;while (l <= r){ll mid = (l + r) >> 1;if (check(mid))r = mid - 1;elsel = mid + 1;}if (r == 1e13)cout << "-1" << endl;elsecout << l << endl;return 0;
}

F.Clear the String

题意

给你一个字符串,每次可以删除一些相同的连续子串,问最少删除几次就可以把整个字符串完全删除。

思路

区间DP,挺简单的。
dp[i][j] = min(dp[i][j], dp[i][mid] + dp[mid + 1][j]);
同时,当区间两端相等的时候,可以免费删除一次。

AC代码

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 7;
char a[maxn];
int dp[maxn][maxn];
void solve(void)
{int n;scanf("%d", &n);scanf("%s", a + 1);memset(dp, 0x3f, sizeof dp);for (int i = 1; i <= n; i++)dp[i][i] = 1;for (int size = 1; size <= n; size++){for (int i = 1; i + size <= n; i++){int j = i + size;if (a[i] == a[j])dp[i][j] = min(dp[i][j - 1], dp[i + 1][j]);for (int mid = i; mid <= j; mid++){dp[i][j] = min(dp[i][j], dp[i][mid] + dp[mid + 1][j]);}}}printf("%d\n", dp[1][n]);
}
int main(void)
{solve();return 0;
}

不能再沉迷与拯救华盛顿了啊!!!!

后记

创作于:2019-03-14 21:51:53
那个时候沉迷于全境封锁2,好像TU6刚刚开始,当时的溜溜球电工比TU8之后的塔防电工和战法牧特工相比起来好玩多了(雾。

Educational-Codeforces-Round-61-ABCDF题解相关推荐

  1. Educational Codeforces Round 61 (Rated for Div. 2)(A、B、C、D、E、F)

    欢迎访问本菜鸡的独立博客:Codecho 比赛名称 Educational Codeforces Round 61 (Rated for Div. 2) 比赛链接 https://codeforces ...

  2. Educational Codeforces Round 138 (A-E)题解

    A Cowardly Rooks 思路:看着还挺复杂的.仔细观察一下题意,题中已经说明初始情况没有两个棋子在同一行或同一列,那么只要有空缺行/空缺列,就可以移动.只要判断n等不等于m就行. 代码: # ...

  3. 【Educational Codeforces Round 61 (Rated for Div. 2)】A.B.C.D.E.F.G

    前言 这场在最开始很顺利,A题6min1A,B题14min1A,但是由于C题过题人数太少一度认为这个C题很难,等有人过了才开始写最开始的想法,C题40min1A,过C之后发现F过的很多,去看提,发现和 ...

  4. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  5. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  6. Educational Codeforces Round 140 (Rated for Div. 2)题解

    看看时间还有十几分钟,开不出来题了,写个题解 A. Cut the Triangle 检查是不是直角边平行于坐标轴的直角三角形即可 这里可以用异或来写,代码较为简洁,我就不改了,直接贴上我的丑代码 c ...

  7. Educational Codeforces Round 95题解

    Educational Codeforces Round 95题解 题目链接 代码链接 A. Buying Torches 题目大意: 你手上现在有一个木棍.有以下两种交换方式: 1.用一个木棍交换x ...

  8. Educational Codeforces Round 133 (Rated for Div. 2)(CD题解)

    Educational Codeforces Round 133 (Rated for Div. 2)CD题解 过AB补CD C. Robot in a Hallway 题意 题意:现有 2∗m 的方 ...

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

    Educational Codeforces Round 76 题解 比赛链接 A. Two Rival Students #include<bits/stdc++.h> using na ...

  10. Educational Codeforces Round 104 (Rated for Div. 2)A-E题解

    Educational Codeforces Round 104 (Rated for Div. 2)A-E题解 比赛链接:https://codeforces.ml/contest/1487 A题 ...

最新文章

  1. Python中的标识符有哪些基础原则?
  2. 使用Pandas的rolling函数计算滚动平均值(rolling average with Pandas rolling)、seaborn使用lineplot函数可视化时间序列数据、并添加滚动平均值
  3. SmartPointer
  4. Eclipse导入项目常见问题----服务器版本问题02
  5. linux经常使用解压缩命令
  6. 博客园官方 NuGet镜像上线试运行
  7. Python函数学习
  8. Gstreamer官方教程汇总2---GStreamer concepts
  9. ​​​​​​​Carryon 数数字
  10. vscode 中怎么打开资源管理器?
  11. 心率检测实现报告(一)
  12. unity3d的Animation 动画播放器的基本API
  13. AI:华为云HiLens Kit试用测评—全栈全场景的人工智能
  14. 什么是AVIF?如何在你的网站上使用AV1格式图像
  15. LeetCode312:戳气球
  16. mac时间机器文件服务器,使用时间机器备份文件 - 处理文件和文件夹 - macOS使用手册...
  17. aspose-words破解版使用java版
  18. Java项目:基于jsp+mysql+Spring+SpringMVC+mybatis的爱康医院专家预约管理系统
  19. python中文件分类_李亚涛:python实现电脑文件一键分类
  20. 基于Matlab Simulink开发的嵌入式模型,模型可自动生成ccs工程代码,生成的代码可直接运行在主控芯片中

热门文章

  1. DIYer 教你如何选购键盘
  2. 服务器安装系统0x0000098,Win10专业版系统出现0xc0000098错误的解决方法
  3. c 与matlab联合编程,MATLAB与C联合编程的实现
  4. illustrator cc 导出html,提取 CSS | Illustrator
  5. Java代码实现—函数递归
  6. 【2023秋招面经】OPPO 前端 一面(40min)
  7. 跟着姜少学Java基础编程之八:循环结构
  8. 2018计算机统考知识点,2018考研之六大步骤解析计算机统考
  9. java 令牌_WEB API - 使用Bearer令牌进行身份验证
  10. vue加载图片失败解决方法