Codeforces 954 E. Water Taps】的更多相关文章

http://codeforces.com/problemset/problem/954/E 式子变成Σ xi*(ti-T)=0 sum0表示>=T的ai*ti之和 sum1表示<T的ai*ti之和 那么如果sum0<sum1,所有ti>=T的ai全加上 那么现在的Σ xi*(ti-T)>=0 考虑用ti<T的来使这个式子变成0,还要让Σ xi 最大 显然是选的ti与T的差距越小 ,xi可以用的越多 将ti从大到小排序后,以此选用,直到式子变成0 sum1<sum…
题目大意 有 $n$($1\le n\le 200000$)个变量 $x_1, x_2, \dots, x_n$,满足 \begin{equation} 0\le x_i \le a_i \label{C:0} \end{equation} 其中 $1\le a_i \le 10^6$,$a_i\in\mathbb Z$ . 给定常数 $T$($1\le T\in\mathbb Z\le 10^6$)以及常数 $t_1, t_2, \dots, t_n$($1\le t_i\in\mathbb…
http://codeforces.com/problemset/problem/954/G 二分答案 检验的时候,从前往后枚举,如果发现某个位置的防御力<二分的值,那么新加的位置肯定是越靠后越好 差分即可 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define N 500001 typedef long…
Discription Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by th…
A B C D 给你一个联通图 给定S,T 要求你加一条边使得ST的最短距离不会减少 问你有多少种方法 因为N<=1000 所以N^2枚举边数 迪杰斯特拉两次 求出Sdis 和 Tdis 如果dis[i]+dis[j]+1>=distance(s,t)&&dis[j]+dis[i]+1>=distance(i,j)就为一条要求边 #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) me…
从这里开始 小结 题目列表 Problem A Diagonal Walking Problem B String Typing Problem C Matrix Walk Problem D Fight Against Traffic Problem E Water Taps Problem F Runner's Problem Problem G Castle Defense Problem H Path Counting Problem I Yet Another String Match…
A. Diagonal Walking 题意 将一个序列中所有的\('RU'\)或者\('UR'\)替换成\('D'\),问最终得到的序列最短长度为多少. 思路 贪心 Code #include <bits/stdc++.h> #define F(i, a, b) for (int i = (a); i < (b); ++i) #define F2(i, a, b) for (int i = (a); i <= (b); ++i) #define dF(i, a, b) for (…
我的代码应该不会被hack,立个flag A. Water The Garden time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output It is winter now, and Max decided it's about time he watered the garden. The garden can be represent…
It is winter now, and Max decided it's about time he watered the garden. The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), which, if turned on, start deliv…
今天是黄致焕老师的讲授~ T1 自信 AC 莫名 80 pts???我还是太菜了!! 对于每种颜色求出该颜色的四个边界,之后枚举边界构成的矩阵中每个元素,如果不等于该颜色就标记那种颜色不能最先使用. 注意特判整张图只有一种颜色的情况.(这个坑点坑掉我 10 pts!) 枚举时注意跳过所有已经被删除的元素.(不然 #8 死活过不去) T2 T3 基础算法 模拟 模拟是算法竞赛中最简单,也是最难的一类题: 简单的地方在于只需要读清楚题目的所有要求并一步步实现就行了: 难点同样必须读清楚题目的所有条件…