因为每个数不能移动到同一位置,所以代价计算会很麻烦,那就钦点让每个数可以移动到同一位置,最后再减去多余代价也就是两个等差数列即可。 现在计算每个数移动到中位数处的距离,注意到每加入一个\(k\)之后中位数的最多会移动\(1\)个位置,且移动之后除了\(k\)以外的值对总代价的贡献不变,直接用set维护\(1\s...
Kinda tricky, but we only need one array, for each query f[s]f[s] stand for maximum value with bag of weight ss upto that query. Inner Part Notice that it is required for the second-inner-loop to iterate from ww downto cici. Here is the reason From c[i] upto w From w downto...
If so, please use AI, cheat, and do everything possible to get to 1600 as soon as possible and get the f**k out of this platform. And if you are (not) a normal person and do competitive programming because it is fun to solve problems, do you think it is fun to copy the proble...
https://codeforces.com/contest/1918/problem/C 1400 加法拆位(进位拆位):涉及到加法进位的题目,可以按照 mod 2^k 拆位 https://atcoder.jp/contests/abc091/tasks/arc092_b 所有a[i]+a[j] 的异或和 https://codeforces.com/problemset/problem/1322/B 2100 ...
题目链接 #题目大意 给无限深度一颗k叉树,每个最小子树的边的权值都是1~k,问有多少从根结点出发,路径和为n且最少一条边为d的路径。 #解题思路 首先看到要取模就知道直接枚举出所有的情况肯定是不可取的。考虑一下,如果有一条路径可以到达n,那之前肯定有路径可以到达n-
from(a, b, c) for(int a = b; a < c; a++)9#defineKEK cout << "KEK\n";1011usingnamespacestd;121314intn, d, k;15intptr =2;1617vector< vector <int> > tree(1000000);1819intdeep[1000000];20intmark[1000000];2122boolfirst_chek() {23if((n -1) <d)24returntrue;2526if(k =...
2019-12-06 10:50 − https://codeforces.com/contest/1265 这场的2E是1C的不带checkpoints的版本。 ##A - Beautiful String 题意:给一个由'a','b','c','?'组成的字符串,把'?'填成前面三种其中之一使得字符串中没有连续两个相同的字符。 首先把... KisekiPurin2019 0 258 Codeforces Round ...
C - Sequence D - Rectangle Painting 1 E - Team Building E - Axis Walking D - Bad Luck Island 概率DP , DP 方程很显然, 就第一种人还剩 i , 第二种人 j , 第三种人 k 的概率, 然后从终态往初态递推即可 每次要计算分开计算概率, 注意细节即可 int p, r, s; double dp[110][...
给定一个长度为n的序列a_1,\cdots,a_n,选定一个正整数k,每次操作选择一个下标i\ \ (1\leq i\leq n),令a_i-=k.经若干次(可能为零次)操作后序列中所有元素相等,求k的最大值.若k可任意大,输出-1. 有t\ \ (1\leq t\leq 10)组测试数据.每组测试数据第一行输入一个偶数n\ \ (4\leq n\le...
1703C: Cypher 题目链接 模拟 代码语言:javascript 复制 #include<bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int solve(){ int n; cin>>n; vector<int>vv(n); for(int i=0; i<n; ++i) cin>>vv[i]; for(int i=0; i<n; ++i){ int k; string s; cin>>k...