C - Snuke Festival ....最后想到了,可是不应该枚举a[],这样要二重循环,而应该枚举b[],这样只需一重循环... #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; ; int a[maxn],b[maxn],c[maxn]; int n; int Fin…
二分水题,A,B,C三个数组排序,对于每个B[i],二分算出来有多少A比他小,多少C比他大,然后扫一遍出结果.O(nlog(n))水过. #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+10; int A[MAXN],B[MAXN],C[MAXN]; int n; //严格小于B[i]的数字个数 和 严格大于B[i]的数字个数 long long lnb[MAXN],unb[MAXN]; int main()…
AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几次操作将三个数变为相同的数. 分析: 可以发现如果三个数的奇偶性相同直接加就可以了,对于奇偶性不同的,先把奇偶性相同的两个数都+1,然后按照相同的处理就可以了.可以证明没有更好的方案. #include <bits/stdc++.h> using namespace std; int a,b,c,…
AtCoder Regular Contest 082 D Derangement 与下标相同与下个交换就好了.... Define a sequence of ’o’ and ’x’ of length N as follows: if pi ̸= i, the i-th symbol is ’o’, otherwise the i-th symbol is ’x’. Our objective is to change this sequence to ’ooo...ooo’.• If the…
/** 题目:D - No Need 链接:http://arc070.contest.atcoder.jp/tasks/arc070_b 题意:给出N个数,从中选出一个子集,若子集和大于等于K,则这是一个Good子集,现在要求这N个数里无用数的个数. 无用数的定义是:在这个数所属的所有Good子集中,如果把这个数删去后原子集仍然是一个Good子集,它就是一个无用数 思路:关键点是存在单调性,如果某个数是必须的,那么比他大的数都是必须的: 证明如下:假设x是必须的,y是比x大的某个数:x是必须的…
原文链接https://www.cnblogs.com/zhouzhendong/p/ARC101D.html 题目传送门 - ARC101D 题意 给定一个序列 A . 定义一个序列 A 的中位数为:给 A 排序,得到的第 $\left\lfloor\cfrac{i}{2}\right\rfloor+1$ 项的值. 序列 B 由序列 A 的所有连续子序列的中位数构成. 问序列 B 的中位数是多少. 序列中可能出现重复的数,$|A| \leq 10^5$ . 题解 注意这里说的“中位数”是题意里…
Problem Statement You are given two integer sequences, each of length N: a1,…,aN and b1,…,bN. There are N2 ways to choose two integers i and j such that 1≤i,j≤N. For each of these N2 pairs, we will compute ai+bj and write it on a sheet of paper. That…
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbe…
地址:http://arc080.contest.atcoder.jp/tasks/arc080_c 题目: E - Young Maids Time limit : 2sec / Memory limit : 256MB Score : 800 points Problem Statement Let N be a positive even number. We have a permutation of (1,2,…,N), p=(p1,p2,…,pN). Snuke is constru…
地址:http://arc080.contest.atcoder.jp/tasks/arc080_b 题目: D - Grid Coloring Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2…
地址:http://arc080.contest.atcoder.jp/tasks/arc080_a 题目: C - 4-adjacent Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement We have a sequence of length N, a=(a1,a2,…,aN). Each ai is a positive integer. Snuke's objective is to…