D. Serega and Fun time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor…
D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/D Description Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up w…
题目传送门 /* 题意:选择a[k]然后a[k]-1和a[k]+1的全部删除,得到点数a[k],问最大点数 DP:状态转移方程:dp[i] = max (dp[i-1], dp[i-2] + (ll) i * cnt[i]); 只和x-1,x-2有关,和顺序无关,x-1不取,x-2取那么累加相同的值,ans = dp[mx] */ #include <cstdio> #include <algorithm> #include <cstring> #include <…
题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; ll dp[MAXN][]; ll cnt[MAXN]; ll work(…
http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Dima and Alex had an argument about the price and quality of laptops. Dima thi…
C. Civilization Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/C Description Andrew plays a game called "Civilization". Dima helps him. The game has n cities and m bidirectional roads. The cities are numbe…
A. Boredom Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/A Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and d…
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. 简单dp,dp[i]表示取i时zui最大和为多少,方程为dp[i] = max(dp[i - 1] , dp[i - 2] + cont[i]*i). #include <bits/stdc++.h> using namespace std; typedef __int64 LL; ; LL a…
题目大意:给你一个长度为n的数组a,然后数值大的可以合并数值小的,且合并了以后该数组的长度-1.给你一个长度为k目标数组b,问,是否可以从a数组变到b数组,是就yes并且输出步骤.否就输出no 思路:因为合并的时候要删除某一个数字,很容易想到用树状数组来维护.然后分析一下就可以得到b中第i个数,一定是由a的某一段区间得到的.我们只要找到这一段区间就行啦. #include <bits/stdc++.h> using namespace std; #pragma comment(linker,&…
题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bored, he comes up with…