Codeforces 1500F - Cupboards Jumps(set)】的更多相关文章

Codeforces 题面传送门 & 洛谷题面传送门 nb tea!!!111 首先很显然的一件事是对于三个数 \(a,b,c\),其最大值与最小值的差就是三个数之间两两绝对值的较大值,即 \(\max(|a-b|,|b-c|,|c-a|)\),因此我们不妨从差分序列的角度解决这个问题.对于原序列 \(h\),我们假设其差分序列 \(d_i=h_{i+1}-h_i\),那么 \(\max(h_i,h_{i+1},h_{i+2})-\min(h_i,h_{i+1},h_{i+2})=\max(|h…
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of i…
http://codeforces.com/gym/101341/problem/K 题意:给出n个区间,每个区间有一个l, r, w,代表区间左端点右端点和区间的权值,现在可以选取一些区间,要求选择的区间不相交,问最大的权和可以是多少,如果权和相同,则选区间长度最短的.要要求输出区间个数和选了哪些区间. 思路:把区间按照右端点排序后,就可以维护从左往右,到p[i].r这个点的时候,已经选择的最大权和是多少,最小长度是多少,区间个数是多少. 因为可以二分找右端点小于等于当前区间的左端点的某个区间…
Watchmen 直接上中文 Descriptions: 钟表匠们的好基友马医生和蛋蛋现在要执行拯救表匠们的任务.在平面内一共有n个表匠,第i个表匠的位置为(xi, yi). 他们需要安排一个任务计划,但是确发现了一些问题很难解决.马医生从第i个表匠到第j个表匠所需要的时间为|xi - xj| + |yi - yj|.然而蛋蛋所需要的时间为 要想成功完成任务,必须保证两人从第i个表匠出发,同时到达第j个表匠.现在请你计算最多有多少组表匠的位置满足条件 Input 第一行只有一个数n( 1 ≤ n…
题目传送门 题目描述 有一个$n\times m$的格子图,其中有一些是黑色的,另一些为白色.从某个白色格子的中心点向左上($NW$),左下($SW$),右上($NE$),右下($SE$)四个方向中的一个发出一束光线,若光线碰到黑色格子或者墙壁(即边界)会反射.反射情况如图所示: 我们不难发现,光线能穿过的格子总数是可以算出的.假如光线经过了某个格子的中心,则称光线经过了这个格子.求光线经过的格子总数.由于答案可能很大,请使用$long\ long$的$C++$选手注意:请勿使用$\%lld$,…
Alice and Bob are playing a game with nn piles of stones. It is guaranteed that nn is an even number. The ii-th pile has aiai stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactl…
题意: 有一个每个单元标明移动方向的长为n的序列,每次移动不能超过距离k,问能够从0移动到n+1的k的最小值. 思路: k=最长连续L序列长度+1. #include <bits/stdc++.h> using namespace std; void solve(){ string s;cin>>s; int mx=1,n=s.size(); for(int i=0;i<n;i++){ int len=1; while(i<n&&s[i]=='L') +…
http://codeforces.com/problemset/problem/540/C       Ice Cave Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 540C Description You play a computer game. Your character stands on some lev…
题目链接:http://codeforces.com/problemset/problem/711/C O(n^4)的复杂度,以为会超时的 思路:dp[i][j][k]表示第i棵数用颜色k涂完后beauty为j #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll inf=1e15; int c[105]; int p[105][105]; ll dp[105][105][105]; int ma…
题目链接: http://codeforces.com/contest/1154/problem/F 题意: 有$n$个物品,$m$条优惠 每个优惠的格式是,买$x_i$个物品,最便宜的$y_i$个物品免费 每条优惠可以无限次使用(当时以为每个优惠只能用一次) 可以买一个物品,不参与优惠 求买k个物品的最低花费 数据范围: $1 \le n, m \le 2 \cdot 10^5, 1 \le k \le min(n, 2000)$$1 \le a_i \le 2 \cdot 10^5$$1 \…