Educational Codeforces Round 59
B. Digital root
题意:
题目定义了x的digital root是S(x)。S(5)=5,S(38)=S(3+8=11)=S(1+1+2)=2.
有n个询问,每次询问给出ki和xi,要你求出digital root为xi的整数中,第k大的是什么。
题解:
观察可以发现,x的digital S(x) 在模9下同余。也就是x mod 9 = S(x).发现这一点以后答案就很显然了。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream> using namespace std;
typedef long long LL;
typedef unsigned long long ull;
int n,x;
LL k;
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%I64d%d",&k,&x);
ull res=x+(k-)*;
printf("%I64u\n",res);
}
return ;
}
C. Brutality
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int maxn=2e5+;
int n,k;
int a[maxn];
char s[maxn]; int main(){
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
scanf("%s",s+);
priority_queue<int,vector<int>,greater<int> >q;
LL ans=;
LL sum=;
int num=;
for(int i=;i<=n;i++){
if(s[i]==s[i-]){
num++;
sum+=a[i];
q.push(a[i]);
if(num>k){
sum-=q.top();
// printf("!%d\n",q.top());
q.pop();
}
}else{
// printf("%d %d\n",i,ans);
ans+=sum;
num=;
sum=a[i];
while(!q.empty())q.pop();
q.push(a[i]);
}
} ans+=sum;
printf("%I64d\n",ans);
return ;
}
D. Compression
题意:
题目给出一个n*n的01矩阵,定义一个x-compression矩阵B,大小为n/x*n/x。使得A[i][j]=B[ceil(i/x)][ceil(j/x)]。显然当n能被x整除时才可能有B矩阵,但是这还不够,请你求出存在B时最大的x是多少。
留坑!
E. Vasya and Binary String
题意:
有一个长度为n的01序列,V要进行以下操作直到序列为空,选则一段连续的都是0或者都是1的子序列删除,然后合并两边剩余的序列。V每次删除一段长度为x的子序列就会得到a[x]分。V希望让得分最高,需要你来帮他!n<=100.
题解:我感觉是好题!
设f[i][j][k]为从i到j全部删除,i包括i前面有k个和i相同的。转移有两种:
1.把第i个和前面相同的一起删除。a[k]+f[i+1][j][1].
2.也可以枚举一个l,当第l个数字等于第i个数字的时候,先把i+1到l-1消掉,然后把第i个和第l个合并到一起。f[i+1][l-1][1]+f[l][j][k+1]。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
const int maxn=+;
int n;
char s[maxn];
int a[maxn];
LL g[maxn];
LL f[maxn][maxn][maxn];
LL dp(int l,int r,int k){
if(f[l][r][k])return f[l][r][k];
if(l>r)return ;
f[l][r][k]=dp(l+,r,)+g[k];
for(int i=l+;i<=r;i++){
if(s[i]==s[l]){
f[l][r][k]=max(f[l][r][k],dp(l+,i-,)+dp(i,r,k+));
}
}
return f[l][r][k];
} int main(){
scanf("%d",&n);
scanf("%s",s+);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
g[i]=a[i];
}
for(int i=;i<=n;i++){
for(int j=;j<i;j++){
g[i]=max(g[i],g[i-j]+g[j]);
}
}
LL res=dp(,n,);
printf("%I64d\n",res); return ;
}
F. Vasya and Endless Credits
题意:
V想要买一辆车,但是他自己一分钱也没有,于是他打算办一些信用卡。有n张信用卡可以选择,每张信用卡用ai,bi,ki来描述。银行会在开始的那个月初给V ai元钱,然后在之后的ki个月(包括开始的那个月)每个月的月末V要还bi元钱。每张信用卡只能用一次,V会在某个月的中间来买车,他能买车的价格为当前手里钱的总数,问V能买的车价格的最大值是多少?
题解:
二分图最大权匹配。假设我们已经知道在哪一天结束。那么左边的点为第i个贷款,右边的点为在倒数第i天贷款,那么左边每个点都要往右边连边,边权为a[i]-min(k,j)*b[i].然后这个题用费用流跑会T?
代码留坑。
G. Vasya and Maximum Profit
题意:
V决定办一场比赛来赚钱。有n个问题可以选择,第i个问题的难度为di,题目是按照难度递增的顺序给出的,且题目的难度各不相同。如果选择第i个问题,V需要付给作者ci元钱。对于比赛的每一道题,V可以获得a元钱。V需要从题目中选择连续的一段。如果V选择的一段是(l,r),那么还要支付gap(l,r)=max(di+1-di)^2.如果l=r,那么gap=0.请你帮忙计算V能获得的最大收益是多少。
题解:
待补···
(我这套刷了个P啊)
Educational Codeforces Round 59的更多相关文章
- Educational Codeforces Round 59 (Rated for Div. 2) DE题解
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...
- Educational Codeforces Round 59 (Rated for Div. 2) E 区间dp + 状态定义 + dp预处理(分步dp)
https://codeforces.com/contest/1107/problem/E 题意 给出01字符串s(n<=100),相邻且相同的字符可以同时消去,一次性消去i个字符的分数是\(a ...
- C. Brutality Educational Codeforces Round 59 (Rated for Div. 2) 贪心+思维
C. Brutality time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Educational Codeforces Round 59 Solution
A. Digits Sequence Dividing 签. #include <bits/stdc++.h> using namespace std; #define N 1010 ch ...
- Educational Codeforces Round 59 (Rated for Div. 2)
熬夜爆肝,智商急剧下降 坐标UTC+8晚上23:35开始 晚上脑袋转的慢,非常慢 T1上来先做还花了好几分钟 T2本来是有式子的我TM写数位DP写炸了然后才发现是有公式 T3英语不好,一开始题意没读懂 ...
- 【考试记录】Educational Codeforces Round 59 (Rated for Div. 2)
本来准备划水,结果被垃圾题艹翻了…… T2题意: 定义一个数$x$的数字根$S(x)$为:将其各位数字相加得到一个新数,再将新数的数字和相加直到得到一个个位数,就是该数的数字根. 例如:$S(38)= ...
- Educational Codeforces Round 59 (Rated for Div. 2) (前四题)
A. Digits Sequence Dividing(英文速读) 练习英语速读的题,我还上来昏迷一次....只要长度大于2那么一定可以等于2那么前面大于后面就行其他no 大于2的时候分成前面1个剩下 ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
随机推荐
- java-appium-527进阶-1 UiAutomator1&2区别和封装
1.UiAutomator和UiAtumator2的区别: 1.1 UiAutomator1有关于id定位的策略 UiAutomator1 id定位在resourceid匹配失败时,会匹配conten ...
- WCF服务部署
一.将WCF服务部署到IIS上 1.首先检测电脑上是否安装了IIS,一般来说Win7以上系统自带IIS 2.下面进行IIS服务的开启设置 控制面板=>打开或关闭Windos功能 3.勾选该窗口中 ...
- css sprite实例
css sprite直译过来就是CSS精灵.通常被解释为“CSS图像拼合”或“CSS贴图定位”.本文章向码农们介绍css sprite使用方法和基本使用实例,需要的码农可以参考一下. 一.什么是css ...
- 资源 | 源自斯坦福CS229,机器学习备忘录在集结
在 Github 上,afshinea 贡献了一个备忘录对经典的斯坦福 CS229 课程进行了总结,内容包括监督学习.无监督学习,以及进修所用的概率与统计.线性代数与微积分等知识. 项目地址:http ...
- 显式锁(四)Lock的等待通知机制Condition
任意一个Java对象,都拥有一组监视器方法(定义在根类Object上),主要包括:wait( ).wait(long timeout).notify().notifyAll()方法:这些方法与关 ...
- JoinableQueue---创建可连接的共享进程队列
创建可连接的共享进程队列.这就像是一个Queue对象,但队列允许项目的使用者通知生产者项目已经被成功处理. 通知进程是使用共享的信号和条件变量来实现的. from multiprocessing im ...
- html_table表格
## `table`表格 表格的常用标签 - `table`表格- `thead`表格头- `tbody`表格主体- `tfoot`表格尾- `th`元素定义表头单元格- `tr`定义表格行- `td ...
- uva-10129-欧拉通路
题意:每一个单词的长度最小2,最大1000,单词开头的字母和另外一个单词的末尾一样就可以连接起来,解所有的单词是不是都可以连接起来,没有遗漏的 把每一个单词的第一个字母当成一个结点,最后一个单词也作为 ...
- HTML5 Canvas ( 画一个五角星 ) lineJoin miterLimit
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- el 表达式的比较和包含
相等( equal ) :eq 不相等( not equal ): ne / neq 大于( greater than ): gt 小于( less than ): lt 大于等于( great th ...