A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th blo…
D. Fish Weight 题目连接: http://www.codeforces.com/contest/298/problem/D Description It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number.…
A. Snow Footprints 如果只有L或者只有R,那么起点和终点都在边界上,否则在两者的边界. B. Sail 每次根据移动后的曼哈顿距离来判断是否移动. C. Parity Game 如果当前1的个数是偶数,则1的个数不会再增加:如果是奇数,则加1后不会再增加. 当前串可以组合成任意种组合,组合中的1不超过最大值. D. Fish Weight \(Diff = \sum{di\cdot wi}\) 假设\(w_1+=dw\),因为有\(0<w_1<=w_2<=\cdots&…
链接: https://codeforces.com/contest/1272/problem/B 题意: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0,0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as…
C. Parity Game 题目连接: http://www.codeforces.com/contest/298/problem/C Description You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes…
B. Sail 题目连接: http://www.codeforces.com/contest/298/problem/B Description The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directio…
C. Alternative Thinking Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/C Description Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary…
A. Bits Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/problem/A Description Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer x. You are given multiple queries…
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers. Unfortunately, the size of a is to…
题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
题目链接:http://codeforces.com/contest/719/problem/B B. Anatoly and Cockroaches time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anatoly lives in the university dorm as many other students do. A…
链接: https://codeforces.com/contest/1272/problem/A 题意: outputstandard output Three friends are going to meet each other. Initially, the first friend stays at the position x=a, the second friend stays at the position x=b and the third friend stays at t…
题目链接:https://codeforces.com/contest/1417/problem/A 题意 给出一个大小为 $n$ 的数组 $a$,每次操作可以选择两个数,然后将一个数加到另一个数上,要求操作后的数不能大于 $k$,问最多可以操作多少次. 题解 除一个最小值外,给每个数一直加最小值. 证明 操作的本质是留下哪一个数,明显留下较小的数更优. 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::syn…
题目链接:https://codeforces.com/contest/1369/problem/E 题意 Lee 有 $n$ 种不同种类的食物和 $m$ 个朋友,每种食物有 $w_i$ 个,每个朋友喜欢吃两种食物 $x_i, y_i$,如果一个朋友被叫去厨房时一个喜欢吃的食物也没有,他就会吃掉 Lee,否则对还有的他喜欢吃的食物一种吃掉一个,问是否存在一个叫朋友去厨房的顺序保证 Lee 不会被吃掉. 题解 设 $s_i$ 为第 $i$ 种食物共需要多少个,若 $w_i \ge s_i$,则喜欢…
题目链接:https://codeforces.com/contest/1369/problem/C 题意 将 $n$ 个数分给 $k$ 个人,每个人分 $w_i$ 个数($\sum_{i = 1}^{k}w_i = n$),每个人的快乐值为分到数的最小值和最大值之和,计算所有人快乐值之和的最大值. 题解 将 $n$ 个数从小到大排序后从两边加起,利用较大的 $w_i$ 跳过尽可能多的较小值. 代码 #include <bits/stdc++.h> using ll = long long;…
C. Recycling Bottles   It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are n bott…
D. Lazy Student   Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to…
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; +; int n, m; int main() { while( ~scanf("%d %d", &n, &m ) ) { ) { printf("1\n"); continue; } ) printf( ); else…
题目链接 给你一个n∗m的矩阵res,让你输出一个n∗m的矩阵a,这个矩阵满足:给你一个n*m的矩阵res,让你输出一个n*m的矩阵a,这个矩阵满足:给你一个n∗m的矩阵res,让你输出一个n∗m的矩阵a,这个矩阵满足: ai,j代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值a_{i,j}代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值ai,j​代表第i行第j列的元素,通过减小res之后,使得第i行,第j列的所有元素的最大值 最小…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
E. Distributing Parts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed…
#include<bits/stdc++.h>using namespace std;int order[300007];long long t[300007],ans[300007];int main(){    int n;    long long m; scanf("%d%lld",&n,&m); for(int i=1;i<=n;i++)  scanf("%lld",&t[i]); t[n+1]=2e18; for…
Description Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day…
D. Minimization time limit per test  2 seconds memory limit per test  256 megabytes input  standard input  output  standard output You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You…
贪心,如果m分成的两个区间长度不相等,那么选长的那个区间最接近m的位置,否则选m-1位置,特判一下n等于1的情况 #include<bits/stdc++.h> using namespace std; int main() { int n,m; scanf("%d%d",&n,&m); ){ printf(; } , d2 = n-m; if(d1<d2){ printf(); }else { printf(); } ; }…
传送门 D. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated…
B. Random Teams   n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a prog…
C. Palindrome Transformation     Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arro…
D. Kindergarten     In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should b…