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没有放在其他套娃里面,那么可 ...
随机推荐
- jeffy-vim-v3.1.tar.gz
下载链接: https://files.cnblogs.com/files/pengdonglin137/jeffy-vim-v3.1.tar.gz 1. 使用sublimemonokai配色 2. ...
- CSS魔法堂:display:none与visibility:hidden的恩怨情仇
前言 还记得面试时被问起"请说说display:none和visibility:hidden的区别"吗?是不是回答完display:none不占用原来的位置,而visibilit ...
- splash
function main(splash, args) splash.images_enabled = false //不加载图片 assert(splash:go(args.url)) assert ...
- C# Task ContinueWith的实现
看了上一篇C# Task 是什么?返回值如何实现? Wait如何实现 我们提到FinishContinuations方法中会调用TaskContinuation实例,那么我们的ContinueWith ...
- JAVA调用外部安装7-Zip压缩和解压zip文件
1.首先在本地安装7-Zip(下载链接:https://www.7-zip.org/)2.调用7-Zip压缩.zip文件: /** * 生成.zip压缩文件 * @param fi ...
- js正则提取数字小数,提取中文,提取英文
var value="污染物:PM2.5"; //提取中文 console.log(value.replace(/[^\u4E00-\u9FA5]/g,'')); //提取英文 c ...
- ESP-EYE V2.1 开发板 WINDOWS 10 开发入门
准备工作 1 × ESP-EYE V2.1 开发板 1 × Micro USB B 电缆 1 × PC(Windows10) 简介 ESP-EYE 是一款面向人脸识别和语音识别市场的开发板,搭载 ES ...
- HTML语言字符编码
! ! — 惊叹号Exclamation mark ” " " 双引号Quotation mark # # — 数字标志Number sign $ $ — 美元标志Dollar s ...
- Guava Preconditions 工具参数前置校验
guava 提供 Preconditions 作为代码校验的工具类,用来简化开发中对代码的校验或预处理,在逻辑开始前进行合理性校验,避免参数传入过深导致的数据错误. 并且能够在不符合校验条件的地方, ...
- 积木式编程——自制app点灯
技术:51单片机.串口.蓝牙.积木式编程 概述 这里简单入门了积木式编程,做了个简易APP用来开灯关灯,当然你可以继续添加内容,可以做智能家居.遥控汽车和环境监控等等. 详细 代码下载:http: ...