题目链接 http://codeforces.com/contest/729/problem/D

题意:给你一个1*n的区域有a艘船,每艘船宽b,已经开了k枪都没打到,问你最少再开几枪至少能打到一艘船。

想清楚了挺简单的,只要找到所有船可能放的地方然后存下再找任意sum-a+1个位置即可。

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int M = 2e5 + 10;
char s[M];
int main()
{
int n , a , b , k;
cin >> n >> a >> b >> k;
cin >> s;
vector<int>q;
int len = strlen(s);
for(int i = 0 ; i + b - 1 < n ; ++i) {
int flag = 0;
for(int j = 0 ; j < b && i < n ; ++j , ++i) {
if(s[i] == '1') {
flag = 1;
break;
}
}
if(!flag) {
q.push_back(i - 1);
i--;
}
}
int gg = q.size() - a + 1;
cout << gg << endl;
for(int i = 0 ; i < gg ; i++) {
cout << q[i] + 1 << ' ';
}
return 0;
}

Codeforces Technocup 2017 - Elimination Round 2 D. Sea Battle(贪心)的更多相关文章

  1. Codeforces Round #380 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 2) D. Sea Battle 模拟

    D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. Codeforces Technocup 2017 - Elimination Round 2 E Subordinates(贪心)

    题目链接 http://codeforces.com/contest/729/problem/E 题意:给你n个人,主管id为s,然后给你n个id,每个id上对应一个数字表示比这个人大的有几个. 最后 ...

  3. Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)

    http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...

  4. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C

    Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B

    Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...

  6. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A

    Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...

  7. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  8. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. codeforces Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)// 二分的题目硬生生想出来ON的算法

    A. Road to Cinema 很明显满足二分性质的题目. 题意:某人在起点处,到终点的距离为s. 汽车租赁公司提供n中车型,每种车型有属性ci(租车费用),vi(油箱容量). 车子有两种前进方式 ...

随机推荐

  1. python协程详解

    目录 python协程详解 一.什么是协程 二.了解协程的过程 1.yield工作原理 2.预激协程的装饰器 3.终止协程和异常处理 4.让协程返回值 5.yield from的使用 6.yield ...

  2. 【POJ - 3258】River Hopscotch(二分)

    River Hopscotch 直接中文 Descriptions 每年奶牛们都要举办各种特殊版本的跳房子比赛,包括在河里从一块岩石跳到另一块岩石.这项激动人心的活动在一条长长的笔直河道中进行,在起点 ...

  3. 使用用树莓派打造远程WEB服务器

    简介:系统配置Raspberry Pi 3B + Raspbian + MySQL5.7 + Tomcat 9 + Nginx + 公网IP. 工具:Win32DiskImager .FileZill ...

  4. Spring Cloud 之 Stream.

    一.简介 Spring Cloud Stream 是一个用来为微服务应用构建消息驱动能力的框架. Spring Cloud Stream 为一些供应商的消息中间件产品(目前集成了 RabbitMQ 和 ...

  5. html的一些基本属性介绍

    一.html的属性类型: 1.常见标签属性: a.<h1>:align对其方式      例如:<h1  align="right"> hhhhh</ ...

  6. axios异步提交表单数据的不同形式

    踩坑Axios提交form表单几种格式 前后端分离的开发前后端, 前端使用的vue,后端的安全模块使用的SpringSecurity,使用postman测试后端的权限接口时发现都正常,但是使用vue+ ...

  7. java并发编程(十四)----(JUC原子类)对象的属性修改类型介绍

    今天我们介绍原子类的最后一个类型--对象的属性修改类型: AtomicIntegerFieldUpdater,AtomicLongFieldUpdater,AtomicReferenceFieldUp ...

  8. aes秘钥限制问题解决办法

    在oarcle jdk1.8上执行256位的aes秘钥加密报错如下: java.lang.RuntimeException: java.security.InvalidKeyException: Il ...

  9. 大话 Spring Session 共享

    javaweb中我们项目稍微正规点,都会用到单点登录这个技术.实现它的方法各家有各界的看法.这几天由于公司项目需求正在研究.下面整理一下最近整理的心得. 简介 在分布式项目中另我们头疼的是多项目之间的 ...

  10. java之面向对象详解

    #############java面向对象详解#############1.面向对象基本概念2.类与对象3.类和对象的定义格式4.对象与内存分析5.封装性6.构造方法7.this关键字8.值传递与引用 ...