Educational Codeforces Round 62
A. Detective Book
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e4 + ;
int N;
int a[maxn];
int maxx = ; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &a[i]); int ans = ;
for(int i = ; i < N; i ++) {
maxx = max(a[i], maxx);
if(maxx == i + ) ans ++;
} printf("%d\n", ans);
return ;
}
B. Good String
代码:
#include <bits/stdc++.h>
using namespace std; int T, N;
string s; int main() {
scanf("%d", &T);
while(T --) {
scanf("%d", &N);
cin >> s;
int st, en;
if(s[] == '>')
printf("0\n");
else if(s[N - ] == '<')
printf("0\n");
else {
for(int i = ; i < N; i ++) {
if(s[i] == '>') {
st = i;
break;
}
}
for(int i = N - ; i >= ; i --) {
if(s[i] == '<') {
en = i;
break;
}
}
printf("%d\n", min(st, N - - en));
}
}
return ;
}
C. Playlist
优先队列 不是很会 看了题解才知道 555
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
int N, K;
int sum[maxn];
int maxx = ; struct Node{
long long t;
long long b;
}node[maxn]; bool cmp(const Node &n1, const Node &n2) {
return n1.b > n2.b;
} int main() {
scanf("%d%d", &N, &K);
for(int i = ; i <= N; i ++)
cin >> node[i].t >> node[i].b; long long sum = , ans = ;;
priority_queue<long long, vector<long long>, greater<long long> > q;
sort(node + , node + + N, cmp);
for(int i = ; i <= N; i ++) {
q.push(node[i].t);
sum += node[i].t;
if(q.size() > K) {
sum -= q.top();
q.pop();
}
ans = max(ans, sum * node[i].b);
} cout << ans << endl; return ;
}
D. Minimum Triangulation
代码:
#include <bits/stdc++.h>
using namespace std; int N;
int dp[]; int main() {
dp[] = ;
for(int i = ; i <= ; i ++)
dp[i] = dp[i - ] + (i * (i - )); scanf("%d", &N);
printf("%d\n", dp[N]);
return ;
}
Educational Codeforces Round 62的更多相关文章
- Educational Codeforces Round 62 (Rated for Div. 2) C 贪心 + 优先队列 + 反向处理
https://codeforces.com/contest/1140/problem/C 题意 每首歌有\(t_i\)和\(b_i\)两个值,最多挑选m首歌,使得sum(\(t_i\))*min(\ ...
- Educational Codeforces Round 62 E 局部dp + 定义状态取消后效性
https://codeforces.com/contest/1140/problem/E 局部dp + 定义状态取消后效性 题意 给你一个某些位置可以改变的字符串,假如字符串存在回文子串,那么这个字 ...
- Educational Codeforces Round 62 Div. 2
突然发现上一场edu忘记写了( A:签到. #include<iostream> #include<cstdio> #include<cmath> #include ...
- Educational Codeforces Round 62 (Rated for Div. 2)C
题目链接 :C. Playlist #include<bits/stdc++.h> using namespace std; #define maxn 300005 #define LL ...
- Educational Codeforces Round 62 (Rated for Div. 2) Solution
最近省队前联考被杭二成七南外什么的吊锤得布星,拿一场Div. 2恢复信心 然后Div.2 Rk3.Div. 1+Div. 2 Rk9,rating大涨200引起舒适 现在的Div. 2都怎么了,最难题 ...
- Educational Codeforces Round 62 (Rated for Div. 2) - C Playlist
当时题意看错了...不过大致思路是对的,唯一没有想到的就是用优先队列搞这个东西,真是不该啊... 题意大概就是,有N首歌,N首歌有两个东西,一个是长度Ti,一个是美丽值Bi,你最多可以选择K首歌, 这 ...
- C. Playlist Educational Codeforces Round 62 (Rated for Div. 2) 贪心+优先队列
C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- Educational Codeforces Round 62 (Rated for Div. 2)
A. Detective Book 题意:一个人读书 给出每一章埋的坑在第几页可以填完 . 一个人一天如果不填完坑他就会一直看 问几天能把这本书看完 思路:模拟一下 取一下过程中最大的坑的页数 如 ...
- Educational Codeforces Round 62 (Rated for Div. 2)E(染色DP,构造,思维,组合数学)
#include<bits/stdc++.h>using namespace std;const long long mod=998244353;long long f[200007][2 ...
随机推荐
- 第35章 秘密(secrets) - Identity Server 4 中文文档(v1.0.0)
在某些情况下,客户端需要使用身份服务器进行身份验证,例如 在令牌端点请求令牌的机密应用程序(也称为客户端) API在内省端点验证引用令牌 为此,您可以将秘密列表分配给客户端或API资源. 秘密解析和验 ...
- Android Studio 关于沉浸式状态栏
values-v19/style.xml <style name="AppTheme" parent="Theme.AppCompat.Light.NoAction ...
- vuex2中使用mapGetters/mapActions报错解决方法
解决方案 可以安装整个stage2的预置器或者安装 Object Rest Operator 的babel插件 babel-plugin-transform-object-rest-spread . ...
- 使用python操作XML增删改查
使用python操作XML增删改查 什么是XML? XML 指可扩展标记语言(EXtensible Markup Language) XML 是一种标记语言,很类似 HTML XML 的设计宗旨是传输 ...
- 广州.NET微软技术俱乐部 - 动手实验室
本文正在写草稿中, 发布时会在群里单独通知
- MAC终端常用语法
这篇文章的重点不在于说是对终端语法的讲解,而是方便大家做语法备忘. 方便查找对应终端语法.所以使用了表格形式对常用终端语法进行了汇总, 但是并没有很多的讲解部分. 当然了这里记录的也都是十分基础的语法 ...
- 人脸识别Android SDK集成
目前我们的应用内使用了ArcFace 的人脸检测功能,这里就和大家分享一下我们的集成过程和一些使用心得~ 集成ArcFace FD 的集成过程非常简单在 ArcFace FD 的文档上有说明支持的系统 ...
- Typora 快捷键
今天学习了一下这个工具.很轻便,很好用的. 无序列表:输入-之后输入空格 有序列表:输入数字+“.”之后输入空格 任务列表:-[空格]空格 文字 标题:ctrl+数字 表格:ctrl+t 生成目录:[ ...
- [spring transaction],service实现类中非事务方法直接调用自身事务方法导致事务无效的原因
首先,准备service接口,两个 public interface AccountService { public void createAccount(Account account, int t ...
- VS2015 IIS Express Web服务器无法启动解决办法
1.运行和调试vs2015项目 提示无法运行项目,打开vs2013项目发现可以正常运行,所以推测试vs2015项目配置有问题. 2.找到项目启动项中 .csproj文件,定位到<WebProje ...