Codeforces Round #264 (Div. 2) 题目链接 A:注意特判正好的情况,其他就一个个去判断记录最大即可 B:扫一遍,不够的用钱去填即可,把多余能量记录下来 C:把主副对角线处理出来,然后黑白只能各选一个最大的放即可 D:转化为DAG最长路问题,每个数字记录
Codeforces Round #264 (Div. 2)
题目链接
A:注意特判正好的情况,其他就一个个去判断记录最大值即可
B:扫一遍,不够的用钱去填即可,把多余能量记录下来
C:把主副对角线处理出来,然后黑格白格只能各选一个最大的放即可
D:转化为DAG最长路问题,每个数字记录下在每个序列的位置,如果一个数字能放上去,那么肯定是每个序列上的数字都是在之前最末尾数字的后面
E:大力出奇迹,预处理出树,然后每次查询从当前位置一直往上找到一个符合的即可,如果没有符合的就是-1
代码:
A:
#include #include #include using namespace std; int n, s; int main() { scanf("%d%d", &n, &s); int x, y; int flag = 1; int ans = 0; for (int i = 0; i
B:
#include #include const int N = 100005; typedef long long ll; int n; ll h[N]; int main() { scanf("%d", &n); for (int i = 1; i h[i - 1]) { ll need = h[i] - h[i - 1]; if (now >= need) { now -= need; } else { ans += need - now; now = 0; } } else { now += h[i - 1] - h[i]; } } printf("%lld\n", ans); return 0; }
C:
#include #include const int N = 2005; typedef long long ll; int n; ll g[N][N], zhu[N + N], fu[N + N]; int main() { scanf("%d", &n); for (int i = 0; i
D:
#include #include #include using namespace std; const int N = 1005; struct Num { int v[10], la; } num[N]; bool cmp(Num a, Num b) { return a.la
E:
#include #include #include using namespace std; const int N = 100005; int n, q, val[N], f[N]; vector g[N]; void dfs(int u, int fa) { f[u] = fa; for (int i = 0; i 1) return u; u = f[u]; } return -1; } int main() { scanf("%d%d", &n, &q); for (int i = 1; i
查看更多关于CodeforcesRound#264(Div.2)的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did96822