Heim >Web-Frontend >HTML-Tutorial >Codeforces Round #264 (Div. 2)_html/css_WEB-ITnose
Codeforces Round #264 (Div. 2)
题目链接
A:注意特判正好的情况,其他就一个个去判断记录最大值即可
B:扫一遍,不够的用钱去填即可,把多余能量记录下来
C:把主副对角线处理出来,然后黑格白格只能各选一个最大的放即可
D:转化为DAG最长路问题,每个数字记录下在每个序列的位置,如果一个数字能放上去,那么肯定是每个序列上的数字都是在之前最末尾数字的后面
E:大力出奇迹,预处理出树,然后每次查询从当前位置一直往上找到一个符合的即可,如果没有符合的就是-1
代码:
A:
#include <cstdio>#include <cstring>#include <algorithm>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 <br> B: <p></p> <p> </p> <pre name="code" class="sycode">#include <cstdio>#include <cstring>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;}</cstring></cstdio>
#include <cstdio>#include <cstring>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 <br> D: <p></p> <p> </p> <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 1005;struct Num { int v[10], la;} num[N];bool cmp(Num a, Num b) { return a.la <br> E: <p></p> <p> </p> <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <vector>using namespace std;const int N = 100005;int n, q, val[N], f[N];vector<int> 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 <br> <br> <p></p> </int></vector></cstring></cstdio>