这场打的顺手到不敢相信.如果不是vp的话估计肯定打不到这个成绩. A:最大显然,最小的话每次暴力给最小的+1. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int read() { ,f=;char c=getchar();…
Codeforces Round #510 (Div. 2) https://codeforces.com/contest/1042 A 二分 #include<iostream> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define pb push_back #define eb emplace_back #…
明明多个几秒就能场上AK了.自闭. A:签到. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long ')) c=getchar();return c;} ?n:gcd(m,n%m);} in…
http://codeforces.com/contest/1042/problem/D 题意 给一个数组n个元素,求有多少个连续的子序列的和<t (1<=n<=200000,abs(a[i])<=1e9) 思路 将公式转化以下,sum[r]-sum[l-1]<t 变成 sum[r]<sum[l-1]+t 可以考虑遍历每个r,先更新sum[r-1]+t,统计有多少满足条件的sum[l-1],反向树状数组维护即可 实现细节 对于每个r是更新他的sum[r-1] 因为要统计…
B. Vitamins 题目链接:https://codeforces.com/contest/1042/problem/B 题意: 给出几种药,没种可能包含一种或多种(最多三种)维生素,现在问要吃到这三种维生素买药最少花费是多少. 题解: 嗯...可以直接暴力: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int n; int c[N]; ]; ]; int main(){ scanf("…
D. Petya and Array 题目链接:https://codeforces.com/contest/1042/problem/D 题意: 给出n个数,问一共有多少个区间,满足区间和小于t. 题解: 假设目前区间右端点为r,左端点为l,那么由前缀和可得知:sumr-suml-1<t,然后我们再边个形:sumr<t+suml-1,根据这个我们可以发现这有点类似于逆序对. 然后我们就可以用求解逆序对问题的解法来解这个问题了,这里不同的就是每次前面的加上t大于当前这个数即为一对逆序对. 我用…
哎,今天第一次打div1 感觉头脑很不清醒... 看到第一题就蒙了,想了好久,怎么乱dp,倒过来插之类的...突然发现不就是一道sb二分吗.....sb二分看了二十分钟........ 然后第二题看了一下,感觉太码农了不可做,然后就cd逛一逛. 突然觉得c可做,就做了一下,交上去wa了,发现有情况没考虑. 这下又滚回了b,结果又没写完...... gg  2040 -83 ->1957 -----------------------------------------------我似分割线啊 A…
A 签到 #include<bits/stdc++.h> using namespace std; ],t[],ans; int main() { scanf("%d%d",&n,&m); ,x;i<=n;i++)scanf(]++; ,x;i<=m;i++)scanf(]++; ans=min(s[],t[])+min(s[],t[]); printf("%d",ans); } B 要求40次,而log(1e6)≍20,也就…
A:求出该行该列各有多少个比其小的取max,该行该列各有多少个比其大的取max,加起来即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define N 1010 char ge…
传送门:Problem C https://www.cnblogs.com/violet-acmer/p/9682082.html 题意: 给你n个数,定义有两种操作 ① 1 i j : (i != j) 将a[i]从数列中移除,且a[j] <- a[i]*a[j] ② 2 i : 将a[i]从数列中移除,此操作最多使用一次 注意:将数移除后剩余数的编号并未改变,依旧为初始时的输入顺序 在经过n-1次操作后使剩余的数最大 题解: 使用操作②的情况: (1) : 数列中含有0 (2) : 负数个数…