E - Post Lamps

思路:一开始看错题,以为一个地方不能重复覆盖,我一想值这不是sb题吗,直接每个power check一下就好。。。。复杂度nlogn

然后发现不是,这样的话,对于每个power,假如我们覆盖到了x,那么我们要找到一个最大的 p <= x 且p 可以放灯,那么转移到的

为止为p + power,这样的话我想复杂度就变成了不是严格的nlogn,但是我写了一发还是过了,我感觉是复杂度接近nlogn,感觉没有

数据能把每个power的check都卡成n。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define piii pair<int, pair<int,int> > using namespace std; const int N = 1e6 + ;
const int M = + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; int n, m, k, s[N], a[N], p[N];
bool b[N];
LL ans = -;
int main() {
scanf("%d%d%d", &n, &m, &k); for(int i = ; i <= m; i++) {
scanf("%d", &s[i]);
b[s[i]] = true;
} for(int i = ; i <= k; i++) {
scanf("%d", &a[i]);
} if(b[]) {
puts("-1");
return ;
}
int pre = ;
for(int i = ; i < n; i++) {
if(!b[i]) pre = i;
p[i] = pre;
} for(int i = ; i <= k; i++) {
bool flag = true;
LL ret = ;
int j = ;
while(j < n) {
if(p[j] + i <= j) {
flag = false;
break;
}
j = p[j] + i;
ret += a[i];
}
if(flag) {
if(ans == - || ret < ans) {
ans = ret;
}
}
} printf("%lld\n", ans);
return ;
}
/*
*/

Educational Codeforces Round 45 (Rated for Div. 2) E - Post Lamps的更多相关文章

  1. Educational Codeforces Round 45 (Rated for Div. 2) C、D

      C. Bracket Sequences Concatenation Problem time limit per test 2 seconds memory limit per test 256 ...

  2. Educational Codeforces Round 45 (Rated for Div. 2) G - GCD Counting

    G - GCD Counting 思路:我猜测了一下gcd的个数不会很多,然后我就用dfs回溯的时候用map暴力合并就好啦. 终判被卡了MLE.....  需要每次清空一下子树的map... #inc ...

  3. Educational Codeforces Round 45 (Rated for Div. 2) F - Flow Control

    F - Flow Control 给你一个有向图,要求你给每条边设置流量,使得所有点的流量符合题目给出的要求. 思路:只有在所有点的流量和为0时有解,因为增加一条边的值不会改变所有点的总流量和, 所以 ...

  4. Educational Codeforces Round 45 (Rated for Div. 2)

    A bracket sequence is a string containing only characters "(" and ")". A regular ...

  5. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  7. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  8. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  9. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

随机推荐

  1. linux下yum错误:[Errno 14] problem making ssl connection Trying other mirror.

    今天是要yum命令安装EPEL仓库后 yum install epel-release 突然发现yum安装其他的软件出错. 错误:[Errno 14] problem making ssl conne ...

  2. ElastAlert监控日志告警Web攻击行为

    由于公司需要监控web攻击行为,而因某些原因搭不了waf,才不得不用ElastAlert进行告警,此为前提. 一.ELK安装 Elasticsearch 是一个分布式.可扩展.实时的搜索与数据分析引擎 ...

  3. Vue入坑教程(一)——搭建vue-cli脚手架

    1. Vue简介 详细内容可以参考官网Vue.js 1)兼容性 Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 无法模拟的 ECMAScript 5 特性.但它支持所有兼容 ECMA ...

  4. Django 2.0.1 官方文档翻译:接下来读什么(page 14)

    接下来读什么(page 14) 现在你应该已经阅读了所有的(page1-13 )介绍材料,决定继续使用Django.我们仅仅做了简要的介绍(事实上,如果你阅读了前面所有的内容,也只是全部文档的5%.) ...

  5. python 常用对linux系统文件及目录的操作

    目录 1.取得当前目录——os.getcwd() >>> import os >>> s=os.getcwd()#获得当前运行脚本所在目录 >>> ...

  6. HDU1693 Eat the Trees(zerojudge a228)

    传送门: https://zerojudge.tw/ShowProblem?problemid=a228 http://acm.hdu.edu.cn/showproblem.php?pid=1693 ...

  7. 20155231 2016-2017-2 《Java程序设计》第7周学习总结

    20155231 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 学习目标 了解Lambda语法 了解方法引用 了解Fucntional与Stream API ...

  8. 20155235 2016-2017-2 《Java程序设计》第六周学习总结

    20155235 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 第十章 InputStream与OutputStreaam 串流设计的概念 串流继承架构 川 ...

  9. 20155315 2016-2017-2 《Java程序设计》第五周学习总结

    教材学习内容总结 第8章 异常处理 1.使用try...catch 与C语言中程序流程和错误处理混在一起不同,Java中把正常流程放try块中,错误(异常)处理放catch块中. 如果父类异常对象在子 ...

  10. 截取汉字 mb_sbstr()

    一.中文截取:mb_substr() mb_substr( $str, $start, $length, $encoding ) $str,需要截断的字符串 $start,截断开始处,起始处为0 $l ...