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. pywinauto: 导入时遇到 "TypeError: LoadLibrary() argument 1 must be string, not unicode"

    pywinauto: 导入时遇到 "TypeError: LoadLibrary() argument 1 must be string, not unicode" 经查询, 看到 ...

  2. 动态改变swiper的属性

    <script> var mySwiper = new Swiper('.swiper-container',{ autoplay : 1000, autoplayDisableOnInt ...

  3. Spring Boot后台启动不打印nohup.out

    #!/bin/bashnohup java -jar websocket-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod --serve ...

  4. 【Foreign】动态规划 [分治][DP]

    动态规划 Time Limit: 50 Sec  Memory Limit: 128 MB Description 一开始有n个数,一段区间的价值为这段区间相同的数的对数. 我们想把这n个数切成恰好k ...

  5. HDU 3535 AreYouBusy (混合背包之分组背包)

    题目链接 Problem Description Happy New Term! As having become a junior, xiaoA recognizes that there is n ...

  6. Mysql服务优化

    Mysql服务优化   Mysql服务加速优化的6个阶段 硬件层面优化 操作系统层面优化 Mysql数据库层面优化 网站集群架构层面优化 安全优化 流程.制度控制优化 1.硬件层面优化 CPU     ...

  7. php的几个面试题

    1. mysql_num_fields() 返回结果集中字段的数目 如: $result = mysql_query("SELECT id,name,age FROM mydb.tb1 wh ...

  8. python——脚本和print

    脚本和print 1.脚本文件 <Python 基础教程>(第二版)中 P118页,原操作为下: 1 _metaclass_ = type 2 3 class Person: 4 def ...

  9. 【日记】NOIP2018

    day-2: 最后一次走出机房,刚下过几天的雨,感受到的是彻骨的寒意.下午离开教室,跟班主任请了接下来几天的假,班主任斜视了我一眼,哼了一声,确认了一下,不再理会我了.班里的同学或是忙着自己的作业,或 ...

  10. 【不知道是啥的NOIP模拟赛】网络入侵

    题意是这样的: 给你一棵树,每个边有一个初始的0/1边权.你希望把它弄成一个给定的样子. 你每次可以选一条树链取反,然后问你最少要操作几次. ----------------------------- ...