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 ...
随机推荐
- 第12章 添加对外部认证的支持 - Identity Server 4 中文文档(v1.0.0)
注意 对于任何先决条件(例如模板),首先要查看概述. 接下来,我们将添加对外部认证的支持.这非常简单,因为您真正需要的是ASP.NET Core兼容的身份验证处理程序. ASP.NET Core本身支 ...
- sql删除数据库重复字段的行
要保留的数据: WITH summary AS ( SELECT p.id, p.customer, p.total, ROW_NUMBER() OVER(PARTITION BY p.custome ...
- JS闭包作用域解析
什么是闭包? 简单理解,当在一个函数的外部访问函数内部定义的变量的时候就会形成一个闭包,由这个理解可以知道,当一个函数执行完成的时候,一般情况下,其作用域会被销毁,其内部定义的变量也会变得不可访问,所 ...
- mongoDB连接数据库
package mongod; import java.util.List; import java.util.ArrayList; import org.bson.types.*; import c ...
- MySQL 笔记整理(4) --深入浅出索引(上)
笔记记录自林晓斌(丁奇)老师的<MySQL实战45讲> 4) --深入浅出索引(上) 一句话简单来说,索引的出现其实就是为了提高数据查询的效率,就像书的目录一样. 索引的常见模型 哈希表: ...
- Spring boot集成spring session实现session共享
最近使用spring boot开发一个系统,nginx做负载均衡分发请求到多个tomcat,此时访问页面会把请求分发到不同的服务器,session是存在服务器端,如果首次访问被分发到A服务器,那么se ...
- spring整合mybatis接口无法注入问题
在学习Spring完之后简单的了解了MyBatis.然后进行简单的整合,遇到MyBatista接口映射的Bean无法自动注入的问题: 代码异常: 线程“main”org.springframe .be ...
- input框限制只能输入正整数、字母、小数、
这篇博文大部分来自于网上,为了方便自己查阅,以及帮助他人. 1,只能输入正整数 <input onkeyup="if(this.value.length==1){this.valu ...
- ecstore 安装后提示require function does not exist in....
解决: 安装好后,修改config.php里的TMP_DIR,指向网站目录下的data目录(用绝对路径) // define('TMP_DIR', '/data/www/data/tmp/'); 先 ...
- AEAI HR薪资汇总功能介绍
1 概述 人力资源系统是一个公司重要的管理工具,而薪资管理是人力资源管理系统中最为核心的功能模块,它包括不同员工的薪资标准.薪资的组成部分,例如:对奖惩管理.保险和年假等员工必备的福利待遇进行统一管理 ...