codeforces R 493 div2
我蓝了!蓝了!!!蒟蒻的蓝色。日常点开friend发现竟然没几个人打??然后去div1看了一下果然学长全都去打div1了呜呜呜。
看到了久违的黄大仙,以为他今晚要上grandmaster,结果打完发现他取消注册了。。。
题外话,div2半小时过完abc,d题推了一个多小时无果,div一千五百人同时在推D题,海上生明月,天涯共此时!(还好我手速快。。。)
上午考完英语三十个单选一百多个选项单词不认识。。。后天高数军理大后天大物,这几天暂时不打了。(好像也只有一场div3
A:我感觉我是瞎做的
all是整个数列的和,然后我们算前缀和sum,只要 sum!=all-sum,那么这个位置之前的都选出来就行了。注意特判个别情况
B:贪心+优先队列(或者存进数组然后排序),所有能分割的地方 都把 花费 存进来,然后前缀和<B就行。
只贴main方法,快速io太长容易引起不适,请忽略我的冒泡排序。。。
public static void main(String[] args) {
int n = nextInt();
int B = nextInt();
int ans[] = new int[n];
int index = 0;
int a[] = new int[n];
for(int i=0;i<n;i++){
a[i] = nextInt();
}
int odd = 0;
int even = 0;
for(int i=0;i<n;i++){
if (a[i]%2==0)
even++;
else
odd++;
if (even==odd){
if (i==n-1){
break;
}else {
ans[index++]=Math.abs(a[i+1]-a[i]);
odd=0;
even=0;
}
}
}
for(int i=0;i<index;i++){
for(int j=i+1;j<index;j++){
if (ans[j]<ans[i]){
int temp = ans[i];
ans[i]=ans[j];
ans[j]=temp;
}
}
}
if (index==0){
out.print(0);
out.flush();
return;
}
int sum[] = new int[index];
sum[0] = ans[0];
for(int i=1;i<index;i++){
sum[i]=sum[i-1]+ans[i];
}
for(int i=0;i<index;i++){
if (sum[i]>B){
out.print(i);
out.flush();
return;
}
}
out.print(index);
out.flush();
return;
}
C:用了十分钟过掉的,,,还是太菜了,看了好久才找到规律
很显然我们要找到 连续 0 子段 的 个数(我太菜了说不清楚),假如有n个,那么我们n次y操作一定可以,或者n-1次x操作加一次y操作。
public static void main(String[] args) {
int n = nextInt();
long x = nextLong();
long y = nextLong();
String s = next();
char ch[] = s.toCharArray();
int num = 0;
for(int i=0;i<n;){
if (ch[i]=='0'){
num++;
for(int j=i;j<n;j++){
if (ch[j]=='1'){
i=j;
break;
}
else if (j==n-1){
i=n;
break;
}
}
}else
i++;
}
if (num==0){
out.print(0);
}
else if (y<=x){
out.print(y*num);
}else {
out.print((num-1)*x+y);
}
out.flush();
}
D:毒瘤啊 刚才看了看学长的代码发现自己的思路竟然是错的,早知道半个小时过掉abc就去睡觉,也不至于今天英语考试一副要死的样子。。。
问题是我真的感觉自己要挂科了,贴一份学长的代码(大家可以努力看看。。。。。)
要是看懂了的话顺便给我讲讲,,考试周了我这种蒟蒻一般不敢打扰学长。。。
#include <iostream>
using namespace std;
typedef long long LL;
LL n; int dp[][], ans[];
void test(){
dp[][]=;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(j>=&&dp[i-][j-]) dp[i][j]=;
if(j>=&&dp[i-][j-]) dp[i][j]=;
if(j>=&&dp[i-][j-]) dp[i][j]=;
if(j>=&&dp[i-][j-]) dp[i][j]=;
}
int cnt=;
for(int j=;j<=;j++) cnt+=dp[i][j];
ans[i]=cnt;
//printf("%d %d\n", i, cnt);
}
} int main() {
test();
cin>>n;
if(n<) printf("%d\n", ans[n]);
else printf("%lld\n", ans[]+(n-)*);
}
下面这个是黄大仙的D题,,,看了下提交记录用了不到十分钟,,不过几乎没有可读性。。。可能这就是神仙吧.jpg
#include<iostream>
#include<cstdio>
#include<bitset>
const int N=;
std::bitset<N> dp[],tmp;
int main() {
dp[][]=;
for(int i=;i<=;i++) {
tmp=dp[i-];
dp[i]|=tmp<<;
dp[i]|=tmp<<;
dp[i]|=tmp<<;
dp[i]|=tmp<<;
}
int n,ans=dp[].count();
scanf("%d",&n);
if(n<=) printf("%d\n",int(dp[n].count()));
else printf("%lld\n",1LL*(n-)*+ans);
return ;
}
codeforces R 493 div2的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- codeforces 572(Div2)A、B、C、D1、D2、E
Cdoeforces 572(Div2)A.B.C.D1.D2.E 传送门:https://codeforces.com/contest/1189 A.题意: 给你一串长为n的字符串,要求你将其切割为 ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round#310 div2
C题:这题说的是套娃,如果做题的时候知道是套娃,那就好理解多了 规则1:套娃A可以放到套娃B里面,当且仅当套娃B没有放在其他套娃里面 规则2:套娃A放在套娃B里面,且套娃B没有放在其他套娃里面,那么可 ...
随机推荐
- 从注册表清理 IE10,IE11 用户代理字符串(UserAgent)中的垃圾信息
某一天,我发现我的 IE User Agent 字符串里面竟然含有刷机大师.百度浏览器等许多垃圾,国货流氓见怪不怪了. 微软自家的.NET CLR也占据了一大片,看着也不爽. 决定清理一下,但是却没找 ...
- java static learning
/*static learning */ class one { public int a = 5; static { // 类加载时就运行代码码 System.out.println("s ...
- git操作中出现Unlink of file '......' failed. Should I try again?
在操作git中有时候会提示 Unlink of file '......' failed. Should I try again? 原因是你工作目录有某些文件正在被程序使用,这个程序多半是Idea,V ...
- python3 图片文字识别
最近用到了图片文字识别这个功能,从网上搜查了一下,决定利用百度的文字识别接口.通过测试发现文字识别率还可以.下面就测试过程简要说明一下 1.注册用户 链接:https://login.bce.baid ...
- php读取ini配置文件属性
ini的内容格式如下,请根据自己的INI,格式修改下段程序. autostart = false font_size = font_color = red =================== fu ...
- VS插件File Nesting
开发者们一直以来都是使用Visual Studio的解决方案管理器 中的嵌套功能管理项目的子文件夹,使得文件组织清晰.便于访问.鉴于现在的项目巨大的文件数目,如果能将这种嵌入能力应用于项目的其他子项上 ...
- 基于java实现的简单区块链
技术:maven3.0.5 + jdk1.8 概述 区块链是分布式数据存储.点对点传输.共识机制.加密算法等计算机技术的新型应用模式.所谓共识机制是区块链系统中实现不同节点之间建立信任.获取权益的 ...
- VMWare 虚机迁移后Linux系统网卡启动问题
重新安装VMWare或拷贝虚机文件后有时网卡会无法工作,主要是因为网卡的Mac地址改变了,如果系统中的网卡配置信息中有Mac的信息,则虚机的系统的网卡可能无法正常工作. 如果出现上述问题,解决办法如下 ...
- Down Payment 和 Deposit的差异
If you’re like most homeowners, purchasing a home represents the single biggest financial transactio ...
- maven创建helloword项目
[root@666 maven_work]# mvn archetype:create -DgroupId=helloword -DartifactId=helloworld [INFO] Scann ...