题目链接: http://codeforces.com/problemset/problem/272/D D. Dima and Two Sequences time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, …
C. Kyoya and Colored Balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/problem/C Description Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k.…
C. Dima and Staircase 线段树维护区间最大值. D. Dima and Two Sequences 由于模数不一定为质数,所以通过拆分质因数来做阶乘取模. E. Dima and Horses 假设一开始所有人都在一个党派里,如果存在不合法的点则改变点的颜色,改变后颜色后与当前颜色相同的点最多只有一个,则继续判断对应点,显然走过去后不会再走回这条边,所以时间复杂度为\(O(M)\).…
C. Dima and Staircase 线段树维护区间最大值. D. Dima and Two Sequences 由于模数不一定为质数,所以通过拆分质因数来做阶乘取模. E. Dima and Horses 假设一开始所有人都在一个党派里,如果存在不合法的点则改变点的颜色,改变后颜色后与当前颜色相同的点最多只有一个,则继续判断对应点,显然走过去后不会再走回这条边,所以时间复杂度为\(O(M)\). D. Dima and Figure 根据题意,构成的连通块是凸的,考虑一行行放,如果某行的…
D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/problem/D Description Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them…
题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过有关,所有数都要取,求最终得到的最大结果 解题思路:dp题,转移方程如下 dp[i][0]=max(dp[i-1][0]+b[i-1],dp[i-1][1]+c[i-1]) dp[i][1]=max(dp[i-1][0]+a[i-1],dp[i-1][1]+b[i-1]) a,b,c分别表示周围没有…
C. Dima and Salad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to…
C. Dima and Salad   Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something. Dima and Seryozha have n fruits in the fridge. Each fruit has…
                                                 D. Dima and Lisa Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at mos…
#include <iostream> #include <algorithm> #include <vector> using namespace std; int check(int a, int b){ ); ) ; ; } int main(){ int n; cin >> n; vector<int> x(n); ; i < n; ++ i) cin >> x[i]; int i; ; i < n ; ++ i)…