Codeforces 387E George and Cards】的更多相关文章

George and Cards 我们找到每个要被删的数字左边和右边第一个比它小的没被删的数字的位置.然后从小到大枚举要被删的数, 求答案. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pa…
E. George and Cards   George is a cat, so he loves playing very much. Vitaly put n cards in a row in front of George. Each card has one integer written on it. All cards had distinct numbers written on them. Let's number the cards from the left to the…
题目链接: 题目 E. George and Cards time limit per test:2 seconds memory limit per test:256 megabytes 问题描述 George is a cat, so he loves playing very much. Vitaly put n cards in a row in front of George. Each card has one integer written on it. All cards had…
Codeforces 731 F. Video Cards 题目大意:给一组数,从中选一个数作lead,要求其他所有数减少为其倍数,再求和.问所求和的最大值. 思路:统计每个数字出现的个数,再做前缀和,用于之后快速求和.将原数组排序后去重,枚举每一个数做lead的情况下,其余数减少后再求和的结果.不断维护最大值即可. PS:这里用到了一个方便的函数unique()来去重,使用前需要先将数组排序,参数为数组的首地址和尾后地址,返回新的尾后地址.(该函数没有将重复的元素删除,只是放到了尾地址后面)可…
题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced t…
题目链接:http://codeforces.com/contest/387/problem/B 题目意思:给出1-n个问题,以及要满足是good rounde条件下这n个问题分别需要达到的complexity,最后还有George已经准备好的关于这些问题的m个complexity.问George要come up with的问题最少有多少个. 很明显要使问题最少,那么满足每个问题的complexity为一个即可.解决这个问题的关键是要理解这句话:He can simplify any alrea…
题目链接:http://codeforces.com/problemset/problem/467/C 题目意思:给出一条含有 n 个数的序列,需要从中找出 k 对,每对长度为 m 的子序列,使得 找出来的k对序列的总和相同.注意,同一个数不能在两个子序列中. 首先用了很暴力的做法,赛后发现过不了test 5 的时候,就知道需要用到 dp 来做了.看了这个人的提示: 其实看完这个状态转移方程,就觉得这题不太难了. dp[i][j]: 前 i 个数中,选择 j pairs 可以获得的最大和. 那么…
题目链接:http://codeforces.com/contest/467/problem/C 求k个不重叠长m的连续子序列的最大和. dp[i][j]表示第i个数的位置个序列的最大和. 前缀和一下就好了.空间可以优化,滚动数组就好了. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cs…
Codeforces Round #227 (Div. 2) E:http://codeforces.com/contest/387/problem/E 题意:给你一个n个数的序列,然后给你一个标准序列,现在然后删除原序列的一些数,让原序列变成标准序列.其中,每次查询可以选择一个连续的序列,然后要删除的数字必须是这个序列中的最小的那个.每一次删除,你可以获得这个长度的价值,问你最多可以得到多少价值. 题解:首先,很明显,每次删除要从要删除的数中选择最小的来删除,而且每次删除就是以包含这个数为最小…
http://codeforces.com/contest/387/problem/E 题意:给你n个数,然后在输入k个数,这k个数都在n个数中出现,进行每一次操作就是在n个数中选择长度为w的连续序列,然后删除这w个数中的最小的一个,然后你就会的到w个奖励,如何获得最多奖励? 思路:set+数状数组,数状数组用来记录在每一个连续的区间内数的个数,用来记录删除和添加数的个数,先对a数组中的数记录每一个数在序列中的位置,再对b数组进行标记,然后遍历1-n,被标记数,把它的位置放在set里面,没有被标…